From 4cde50516b27c7f5f71b19214bb790acc1bace3b Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Fri, 23 Aug 2024 07:40:24 +0000 Subject: [PATCH] CodeGen from PR 3485 in test-repo-billy/azure-rest-api-specs Merge 8a902f8809c8533025263b1641caf63032db8e5b into c221294c903b4bcbe7b1ee4bce901322a7056943 --- .../azure-mgmt-azurestackhci/README.md | 4 +- .../azure-mgmt-azurestackhci/_meta.json | 12 +- .../azurestackhci/_azure_stack_hci_client.py | 93 +- .../mgmt/azurestackhci/_configuration.py | 13 +- .../azure/mgmt/azurestackhci/_patch.py | 1 + .../mgmt/azurestackhci/_serialization.py | 94 +- .../azure/mgmt/azurestackhci/_vendor.py | 16 - .../azure/mgmt/azurestackhci/_version.py | 2 +- .../aio/_azure_stack_hci_client.py | 96 +- .../mgmt/azurestackhci/aio/_configuration.py | 13 +- .../azure/mgmt/azurestackhci/aio/_patch.py | 1 + .../azurestackhci/aio/operations/__init__.py | 28 +- .../operations/_arc_settings_operations.py | 980 +++ .../aio/operations/_clusters_operations.py | 1144 +++ .../_deployment_settings_operations.py | 542 ++ .../operations/_edge_devices_operations.py | 711 ++ .../aio/operations/_extensions_operations.py | 1005 +++ .../operations/_gallery_images_operations.py | 313 +- .../aio/operations/_guest_agent_operations.py | 179 +- .../operations/_guest_agents_operations.py | 39 +- .../_hybrid_identity_metadata_operations.py | 60 +- .../_logical_networks_operations.py | 314 +- .../_marketplace_gallery_images_operations.py | 316 +- .../_network_interfaces_operations.py | 313 +- .../aio/operations/_offers_operations.py | 319 + .../aio/operations/_operations.py | 123 +- .../aio/operations/_publishers_operations.py | 202 + .../_security_settings_operations.py | 542 ++ .../aio/operations/_skus_operations.py | 235 + .../_storage_containers_operations.py | 313 +- .../aio/operations/_update_runs_operations.py | 492 ++ .../_update_summaries_operations.py | 450 + .../aio/operations/_updates_operations.py | 588 ++ .../_virtual_hard_disks_operations.py | 313 +- .../_virtual_machine_instances_operations.py | 473 +- .../mgmt/azurestackhci/models/__init__.py | 214 + .../models/_azure_stack_hci_client_enums.py | 327 +- .../mgmt/azurestackhci/models/_models_py3.py | 7815 +++++++++++++---- .../mgmt/azurestackhci/operations/__init__.py | 28 +- .../operations/_arc_settings_operations.py | 1279 +++ .../operations/_clusters_operations.py | 1423 +++ .../_deployment_settings_operations.py | 693 ++ .../operations/_edge_devices_operations.py | 831 ++ .../operations/_extensions_operations.py | 1233 +++ .../operations/_gallery_images_operations.py | 325 +- .../operations/_guest_agent_operations.py | 185 +- .../operations/_guest_agents_operations.py | 41 +- .../_hybrid_identity_metadata_operations.py | 64 +- .../_logical_networks_operations.py | 326 +- .../_marketplace_gallery_images_operations.py | 328 +- .../_network_interfaces_operations.py | 325 +- .../operations/_offers_operations.py | 438 + .../azurestackhci/operations/_operations.py | 121 +- .../operations/_publishers_operations.py | 269 + .../_security_settings_operations.py | 693 ++ .../operations/_skus_operations.py | 327 + .../_storage_containers_operations.py | 325 +- .../operations/_update_runs_operations.py | 645 ++ .../_update_summaries_operations.py | 572 ++ .../operations/_updates_operations.py | 752 ++ .../_virtual_hard_disks_operations.py | 325 +- .../_virtual_machine_instances_operations.py | 489 +- .../consent_and_install_default_extensions.py | 43 + .../generated_samples/create_arc_identity.py | 43 + .../generated_samples/create_cluster.py | 51 + .../create_cluster_identity.py | 42 + .../generated_samples/create_guest_agent.py | 3 +- .../generated_samples/delete_arc_setting.py | 42 + .../generated_samples/delete_cluster.py | 41 + .../delete_deployment_settings.py | 41 + .../generated_samples/delete_edge_devices.py | 40 + .../generated_samples/delete_extension.py | 43 + .../generated_samples/delete_gallery_image.py | 3 +- .../generated_samples/delete_guest_agent.py | 3 +- .../delete_logical_network.py | 3 +- .../delete_marketplace_gallery_image.py | 3 +- .../delete_network_interface.py | 3 +- .../delete_security_settings.py | 41 + .../delete_storage_container.py | 3 +- .../generated_samples/delete_update_runs.py | 43 + .../delete_update_summaries.py | 41 + .../generated_samples/delete_updates.py | 42 + .../delete_virtual_hard_disk.py | 3 +- .../delete_virtual_machine_instance.py | 3 +- .../extend_software_assurance_benefit.py | 43 + .../generated_samples/extensions_upgrade.py | 44 + .../generated_samples/generate_password.py | 43 + .../generated_samples/get_arc_setting.py | 43 + .../generated_samples/get_cluster.py | 42 + .../get_deployment_settings.py | 42 + .../generated_samples/get_edge_devices.py | 41 + .../generated_samples/get_extension.py | 44 + .../generated_samples/get_gallery_image.py | 3 +- .../generated_samples/get_guest_agent.py | 3 +- .../get_hybrid_identity_metadata.py | 3 +- .../generated_samples/get_logical_network.py | 3 +- .../get_marketplace_gallery_image.py | 3 +- .../get_network_interface.py | 3 +- .../generated_samples/get_offer.py | 44 + .../generated_samples/get_publisher.py | 43 + .../get_security_settings.py | 42 + .../generated_samples/get_sku.py | 45 + .../get_storage_container.py | 3 +- .../generated_samples/get_update_runs.py | 44 + .../generated_samples/get_update_summaries.py | 42 + .../generated_samples/get_updates.py | 43 + .../get_virtual_hard_disk.py | 3 +- .../get_virtual_machine_instance.py | 3 +- .../generated_samples/guest_agent_list.py | 3 +- .../hybrid_identity_metadata_list.py | 3 +- .../initialize_disable_process.py | 42 + .../list_arc_settings_by_cluster.py | 43 + .../list_clusters_by_resource_group.py | 42 + .../list_clusters_by_subscription.py | 40 + .../list_deployment_settings_by_cluster.py | 43 + .../generated_samples/list_edge_devices.py | 42 + .../list_extensions_by_arc_setting.py | 44 + .../list_gallery_image_by_resource_group.py | 3 +- .../list_gallery_image_by_subscription.py | 3 +- .../list_logical_network_by_resource_group.py | 3 +- .../list_logical_network_by_subscription.py | 3 +- ...etplace_gallery_image_by_resource_group.py | 3 +- ...rketplace_gallery_image_by_subscription.py | 3 +- ...ist_network_interface_by_resource_group.py | 3 +- .../list_network_interface_by_subscription.py | 3 +- .../list_offers_by_cluster.py | 43 + .../list_offers_by_publisher.py | 44 + .../generated_samples/list_operations.py | 6 +- .../list_publishers_by_cluster.py | 43 + .../list_security_settings_by_cluster.py | 43 + .../generated_samples/list_skus_by_offer.py | 45 + ...ist_storage_container_by_resource_group.py | 3 +- .../list_storage_container_by_subscription.py | 3 +- .../generated_samples/list_update_runs.py | 44 + .../list_update_summaries.py | 43 + .../generated_samples/list_updates.py | 43 + ...ist_virtual_hard_disk_by_resource_group.py | 3 +- .../list_virtual_hard_disk_by_subscription.py | 3 +- .../list_virtual_machine_instances.py | 3 +- .../generated_samples/patch_arc_setting.py | 51 + .../generated_samples/patch_extension.py | 54 + .../generated_samples/post_updates.py | 42 + .../put_deployment_settings.py | 132 + .../generated_samples/put_edge_devices.py | 61 + .../generated_samples/put_extension.py | 56 + .../generated_samples/put_gallery_image.py | 3 +- .../generated_samples/put_logical_network.py | 3 +- .../put_marketplace_gallery_image.py | 3 +- .../put_network_interface.py | 3 +- .../put_security_settings.py | 43 + .../put_storage_container.py | 3 +- .../generated_samples/put_update_runs.py | 69 + .../generated_samples/put_update_summaries.py | 52 + .../generated_samples/put_updates.py | 70 + .../put_virtual_hard_disk.py | 3 +- ...ual_machine_instance_with_gallery_image.py | 3 +- ...instance_with_marketplace_gallery_image.py | 3 +- ...t_virtual_machine_instance_with_os_disk.py | 3 +- ...l_machine_instance_with_vm_config_agent.py | 3 +- .../restart_virtual_machine_instance.py | 3 +- .../start_virtual_machine_instance.py | 3 +- .../stop_virtual_machine_instance.py | 3 +- .../generated_samples/update_cluster.py | 50 + .../generated_samples/update_gallery_image.py | 3 +- .../update_logical_network.py | 3 +- .../update_marketplace_gallery_image.py | 3 +- .../update_network_interface.py | 3 +- .../update_storage_container.py | 3 +- .../update_virtual_hard_disk.py | 3 +- .../update_virtual_machine_instance.py | 3 +- .../generated_samples/upload_certificate.py | 42 + .../generated_tests/conftest.py | 35 + ...azure_stack_hci_arc_settings_operations.py | 161 + ...stack_hci_arc_settings_operations_async.py | 168 + ...est_azure_stack_hci_clusters_operations.py | 213 + ...ure_stack_hci_clusters_operations_async.py | 222 + ...tack_hci_deployment_settings_operations.py | 196 + ...ci_deployment_settings_operations_async.py | 203 + ...azure_stack_hci_edge_devices_operations.py | 109 + ...stack_hci_edge_devices_operations_async.py | 116 + ...t_azure_stack_hci_extensions_operations.py | 154 + ...e_stack_hci_extensions_operations_async.py | 163 + ...ure_stack_hci_gallery_images_operations.py | 120 + ...ack_hci_gallery_images_operations_async.py | 127 + ..._azure_stack_hci_guest_agent_operations.py | 52 + ..._stack_hci_guest_agent_operations_async.py | 57 + ...azure_stack_hci_guest_agents_operations.py | 30 + ...stack_hci_guest_agents_operations_async.py | 31 + ...hci_hybrid_identity_metadata_operations.py | 41 + ...brid_identity_metadata_operations_async.py | 42 + ...e_stack_hci_logical_networks_operations.py | 138 + ...k_hci_logical_networks_operations_async.py | 145 + ...i_marketplace_gallery_images_operations.py | 119 + ...etplace_gallery_images_operations_async.py | 126 + ...stack_hci_network_interfaces_operations.py | 124 + ...hci_network_interfaces_operations_async.py | 131 + .../test_azure_stack_hci_offers_operations.py | 58 + ...azure_stack_hci_offers_operations_async.py | 59 + .../test_azure_stack_hci_operations.py | 29 + .../test_azure_stack_hci_operations_async.py | 30 + ...t_azure_stack_hci_publishers_operations.py | 44 + ...e_stack_hci_publishers_operations_async.py | 45 + ..._stack_hci_security_settings_operations.py | 92 + ..._hci_security_settings_operations_async.py | 97 + .../test_azure_stack_hci_skus_operations.py | 48 + ...t_azure_stack_hci_skus_operations_async.py | 49 + ...stack_hci_storage_containers_operations.py | 114 + ...hci_storage_containers_operations_async.py | 121 + ..._azure_stack_hci_update_runs_operations.py | 111 + ..._stack_hci_update_runs_operations_async.py | 114 + ...e_stack_hci_update_summaries_operations.py | 108 + ...k_hci_update_summaries_operations_async.py | 111 + ...test_azure_stack_hci_updates_operations.py | 133 + ...zure_stack_hci_updates_operations_async.py | 138 + ...stack_hci_virtual_hard_disks_operations.py | 119 + ...hci_virtual_hard_disks_operations_async.py | 126 + ...ci_virtual_machine_instances_operations.py | 210 + ...tual_machine_instances_operations_async.py | 228 + .../azure-mgmt-azurestackhci/setup.py | 12 +- 219 files changed, 33295 insertions(+), 5385 deletions(-) delete mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/_vendor.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_arc_settings_operations.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_clusters_operations.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_deployment_settings_operations.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_edge_devices_operations.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_extensions_operations.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_offers_operations.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_publishers_operations.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_security_settings_operations.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_skus_operations.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_update_runs_operations.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_update_summaries_operations.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_updates_operations.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_arc_settings_operations.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_clusters_operations.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_deployment_settings_operations.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_edge_devices_operations.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_extensions_operations.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_offers_operations.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_publishers_operations.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_security_settings_operations.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_skus_operations.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_update_runs_operations.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_update_summaries_operations.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_updates_operations.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/consent_and_install_default_extensions.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/create_arc_identity.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/create_cluster.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/create_cluster_identity.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_arc_setting.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_cluster.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_deployment_settings.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_edge_devices.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_extension.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_security_settings.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_update_runs.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_update_summaries.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_updates.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/extend_software_assurance_benefit.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/extensions_upgrade.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/generate_password.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_arc_setting.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_cluster.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_deployment_settings.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_edge_devices.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_extension.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_offer.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_publisher.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_security_settings.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_sku.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_update_runs.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_update_summaries.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_updates.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/initialize_disable_process.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_arc_settings_by_cluster.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_clusters_by_resource_group.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_clusters_by_subscription.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_deployment_settings_by_cluster.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_edge_devices.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_extensions_by_arc_setting.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_offers_by_cluster.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_offers_by_publisher.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_publishers_by_cluster.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_security_settings_by_cluster.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_skus_by_offer.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_update_runs.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_update_summaries.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_updates.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/patch_arc_setting.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/patch_extension.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/post_updates.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_deployment_settings.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_edge_devices.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_extension.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_security_settings.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_update_runs.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_update_summaries.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_updates.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/update_cluster.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/upload_certificate.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/conftest.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_arc_settings_operations.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_arc_settings_operations_async.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_clusters_operations.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_clusters_operations_async.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_deployment_settings_operations.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_deployment_settings_operations_async.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_edge_devices_operations.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_edge_devices_operations_async.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_extensions_operations.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_extensions_operations_async.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_gallery_images_operations.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_gallery_images_operations_async.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_guest_agent_operations.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_guest_agent_operations_async.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_guest_agents_operations.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_guest_agents_operations_async.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_hybrid_identity_metadata_operations.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_hybrid_identity_metadata_operations_async.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_logical_networks_operations.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_logical_networks_operations_async.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_marketplace_gallery_images_operations.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_marketplace_gallery_images_operations_async.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_network_interfaces_operations.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_network_interfaces_operations_async.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_offers_operations.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_offers_operations_async.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_operations.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_operations_async.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_publishers_operations.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_publishers_operations_async.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_security_settings_operations.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_security_settings_operations_async.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_skus_operations.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_skus_operations_async.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_storage_containers_operations.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_storage_containers_operations_async.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_update_runs_operations.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_update_runs_operations_async.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_update_summaries_operations.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_update_summaries_operations_async.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_updates_operations.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_updates_operations_async.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_virtual_hard_disks_operations.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_virtual_hard_disks_operations_async.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_virtual_machine_instances_operations.py create mode 100644 sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_virtual_machine_instances_operations_async.py diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/README.md b/sdk/azurestackhci/azure-mgmt-azurestackhci/README.md index 6f63b4286d4b..b789bc3caed3 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/README.md +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/README.md @@ -1,7 +1,7 @@ # Microsoft Azure SDK for Python This is the Microsoft Azure Azure Stack HCI Management Client Library. -This package has been tested with Python 3.7+. +This package has been tested with Python 3.8+. For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). ## _Disclaimer_ @@ -12,7 +12,7 @@ _Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For ### Prerequisites -- Python 3.7+ is required to use this package. +- Python 3.8+ is required to use this package. - [Azure subscription](https://azure.microsoft.com/free/) ### Install the package diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/_meta.json b/sdk/azurestackhci/azure-mgmt-azurestackhci/_meta.json index dbf99c47afac..b99f24947254 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/_meta.json +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/_meta.json @@ -1,11 +1,11 @@ { - "commit": "43c5786b7d90124e46fe068894694ac899965948", - "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.9.7", + "commit": "1a9e8452e030be747fe4ba3c693c5b8c29fb9039", + "repository_url": "https://github.com/test-repo-billy/azure-rest-api-specs", + "autorest": "3.10.2", "use": [ - "@autorest/python@6.7.1", - "@autorest/modelerfour@4.26.2" + "@autorest/python@6.19.0", + "@autorest/modelerfour@4.27.0" ], - "autorest_command": "autorest specification/azurestackhci/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.7.1 --use=@autorest/modelerfour@4.26.2 --version=3.9.7 --version-tolerant=False", + "autorest_command": "autorest specification/azurestackhci/resource-manager/readme.md --generate-sample=True --generate-test=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.19.0 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", "readme": "specification/azurestackhci/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/_azure_stack_hci_client.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/_azure_stack_hci_client.py index 924b21a1430f..8b6427cacd42 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/_azure_stack_hci_client.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/_azure_stack_hci_client.py @@ -8,14 +8,22 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from . import models as _models from ._configuration import AzureStackHCIClientConfiguration from ._serialization import Deserializer, Serializer from .operations import ( + ArcSettingsOperations, + ClustersOperations, + DeploymentSettingsOperations, + EdgeDevicesOperations, + ExtensionsOperations, GalleryImagesOperations, GuestAgentOperations, GuestAgentsOperations, @@ -23,8 +31,15 @@ LogicalNetworksOperations, MarketplaceGalleryImagesOperations, NetworkInterfacesOperations, + OffersOperations, Operations, + PublishersOperations, + SecuritySettingsOperations, + SkusOperations, StorageContainersOperations, + UpdateRunsOperations, + UpdateSummariesOperations, + UpdatesOperations, VirtualHardDisksOperations, VirtualMachineInstancesOperations, ) @@ -37,10 +52,18 @@ class AzureStackHCIClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Azure Stack HCI management service. + :ivar arc_settings: ArcSettingsOperations operations + :vartype arc_settings: azure.mgmt.azurestackhci.operations.ArcSettingsOperations + :ivar clusters: ClustersOperations operations + :vartype clusters: azure.mgmt.azurestackhci.operations.ClustersOperations + :ivar deployment_settings: DeploymentSettingsOperations operations + :vartype deployment_settings: azure.mgmt.azurestackhci.operations.DeploymentSettingsOperations + :ivar edge_devices: EdgeDevicesOperations operations + :vartype edge_devices: azure.mgmt.azurestackhci.operations.EdgeDevicesOperations + :ivar extensions: ExtensionsOperations operations + :vartype extensions: azure.mgmt.azurestackhci.operations.ExtensionsOperations :ivar gallery_images: GalleryImagesOperations operations :vartype gallery_images: azure.mgmt.azurestackhci.operations.GalleryImagesOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.azurestackhci.operations.Operations :ivar logical_networks: LogicalNetworksOperations operations :vartype logical_networks: azure.mgmt.azurestackhci.operations.LogicalNetworksOperations :ivar marketplace_gallery_images: MarketplaceGalleryImagesOperations operations @@ -48,8 +71,24 @@ class AzureStackHCIClient: # pylint: disable=client-accepts-api-version-keyword azure.mgmt.azurestackhci.operations.MarketplaceGalleryImagesOperations :ivar network_interfaces: NetworkInterfacesOperations operations :vartype network_interfaces: azure.mgmt.azurestackhci.operations.NetworkInterfacesOperations + :ivar offers: OffersOperations operations + :vartype offers: azure.mgmt.azurestackhci.operations.OffersOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.azurestackhci.operations.Operations + :ivar publishers: PublishersOperations operations + :vartype publishers: azure.mgmt.azurestackhci.operations.PublishersOperations + :ivar security_settings: SecuritySettingsOperations operations + :vartype security_settings: azure.mgmt.azurestackhci.operations.SecuritySettingsOperations + :ivar skus: SkusOperations operations + :vartype skus: azure.mgmt.azurestackhci.operations.SkusOperations :ivar storage_containers: StorageContainersOperations operations :vartype storage_containers: azure.mgmt.azurestackhci.operations.StorageContainersOperations + :ivar update_runs: UpdateRunsOperations operations + :vartype update_runs: azure.mgmt.azurestackhci.operations.UpdateRunsOperations + :ivar update_summaries: UpdateSummariesOperations operations + :vartype update_summaries: azure.mgmt.azurestackhci.operations.UpdateSummariesOperations + :ivar updates: UpdatesOperations operations + :vartype updates: azure.mgmt.azurestackhci.operations.UpdatesOperations :ivar virtual_hard_disks: VirtualHardDisksOperations operations :vartype virtual_hard_disks: azure.mgmt.azurestackhci.operations.VirtualHardDisksOperations :ivar virtual_machine_instances: VirtualMachineInstancesOperations operations @@ -68,8 +107,8 @@ class AzureStackHCIClient: # pylint: disable=client-accepts-api-version-keyword :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 "2023-09-01-preview". Note that overriding - this default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2024-01-01". Note that overriding this + default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. @@ -85,14 +124,38 @@ def __init__( self._config = AzureStackHCIClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + ARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **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.arc_settings = ArcSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.clusters = ClustersOperations(self._client, self._config, self._serialize, self._deserialize) + self.deployment_settings = DeploymentSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.edge_devices = EdgeDevicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.extensions = ExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) self.gallery_images = GalleryImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.logical_networks = LogicalNetworksOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -102,9 +165,21 @@ def __init__( self.network_interfaces = NetworkInterfacesOperations( self._client, self._config, self._serialize, self._deserialize ) + self.offers = OffersOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.publishers = PublishersOperations(self._client, self._config, self._serialize, self._deserialize) + self.security_settings = SecuritySettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) self.storage_containers = StorageContainersOperations( self._client, self._config, self._serialize, self._deserialize ) + self.update_runs = UpdateRunsOperations(self._client, self._config, self._serialize, self._deserialize) + self.update_summaries = UpdateSummariesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.updates = UpdatesOperations(self._client, self._config, self._serialize, self._deserialize) self.virtual_hard_disks = VirtualHardDisksOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -117,7 +192,7 @@ def __init__( self.guest_agent = GuestAgentOperations(self._client, self._config, self._serialize, self._deserialize) self.guest_agents = GuestAgentsOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -137,12 +212,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() - def __enter__(self) -> "AzureStackHCIClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/_configuration.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/_configuration.py index 0230c9430f5b..35b9022b5cd3 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/_configuration.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/_configuration.py @@ -8,7 +8,6 @@ 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 @@ -19,7 +18,7 @@ from azure.core.credentials import TokenCredential -class AzureStackHCIClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class AzureStackHCIClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for AzureStackHCIClient. Note that all parameters used to create this instance are saved as instance @@ -29,14 +28,13 @@ class AzureStackHCIClientConfiguration(Configuration): # pylint: disable=too-ma :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2023-09-01-preview". Note that overriding - this default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2024-01-01". Note that overriding this + default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AzureStackHCIClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2023-09-01-preview") + api_version: str = kwargs.pop("api_version", "2024-01-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -48,6 +46,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-azurestackhci/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: 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.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/_patch.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/_patch.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/_patch.py @@ -25,6 +25,7 @@ # # -------------------------------------------------------------------------- + # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/_serialization.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/_serialization.py index 4bae2292227b..8139854b97bb 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/_serialization.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/_serialization.py @@ -63,8 +63,8 @@ import isodate # type: ignore -from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback -from azure.core.serialization import NULL as AzureCoreNull +from azure.core.exceptions import DeserializationError, SerializationError +from azure.core.serialization import NULL as CoreNull _BOM = codecs.BOM_UTF8.decode(encoding="utf-8") @@ -124,7 +124,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: pass return ET.fromstring(data_as_str) # nosec - except ET.ParseError: + except ET.ParseError as err: # It might be because the server has an issue, and returned JSON with # content-type XML.... # So let's try a JSON load, and if it's still broken @@ -143,7 +143,9 @@ def _json_attemp(data): # The function hack is because Py2.7 messes up with exception # context otherwise. _LOGGER.critical("Wasn't XML not JSON, failing") - raise_with_traceback(DeserializationError, "XML is invalid") + raise DeserializationError("XML is invalid") from err + elif content_type.startswith("text/"): + return data_as_str raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) @classmethod @@ -170,13 +172,6 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], return None -try: - basestring # type: ignore - unicode_str = unicode # type: ignore -except NameError: - basestring = str - unicode_str = str - _LOGGER = logging.getLogger(__name__) try: @@ -295,7 +290,7 @@ class Model(object): _validation: Dict[str, Dict[str, Any]] = {} def __init__(self, **kwargs: Any) -> None: - self.additional_properties: Dict[str, Any] = {} + self.additional_properties: Optional[Dict[str, Any]] = {} for k in kwargs: if k not in self._attribute_map: _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) @@ -340,7 +335,7 @@ def _create_xml_node(cls): return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: - """Return the JSON that would be sent to azure from this model. + """Return the JSON that would be sent to server from this model. This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. @@ -351,7 +346,7 @@ def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) + return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) # type: ignore def as_dict( self, @@ -390,7 +385,7 @@ def my_key_transformer(key, attr_desc, value): :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) + return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) # type: ignore @classmethod def _infer_class_models(cls): @@ -415,7 +410,7 @@ def deserialize(cls: Type[ModelType], data: Any, content_type: Optional[str] = N :raises: DeserializationError if something went wrong """ deserializer = Deserializer(cls._infer_class_models()) - return deserializer(cls.__name__, data, content_type=content_type) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def from_dict( @@ -445,7 +440,7 @@ def from_dict( if key_extractors is None else key_extractors ) - return deserializer(cls.__name__, data, content_type=content_type) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def _flatten_subtype(cls, key, objects): @@ -545,7 +540,7 @@ class Serializer(object): "multiple": lambda x, y: x % y != 0, } - def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): + def __init__(self, classes: Optional[Mapping[str, type]] = None): self.serialize_type = { "iso-8601": Serializer.serialize_iso, "rfc-1123": Serializer.serialize_rfc, @@ -561,7 +556,7 @@ def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): "[]": self.serialize_iter, "{}": self.serialize_dict, } - self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} + self.dependencies: Dict[str, type] = dict(classes) if classes else {} self.key_transformer = full_restapi_key_transformer self.client_side_validation = True @@ -649,7 +644,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs): else: # That's a basic type # Integrate namespace if necessary local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) - local_node.text = unicode_str(new_attr) + local_node.text = str(new_attr) serialized.append(local_node) # type: ignore else: # JSON for k in reversed(keys): # type: ignore @@ -668,7 +663,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs): except (AttributeError, KeyError, TypeError) as err: msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) - raise_with_traceback(SerializationError, msg, err) + raise SerializationError(msg) from err else: return serialized @@ -710,7 +705,7 @@ def body(self, data, data_type, **kwargs): ] data = deserializer._deserialize(data_type, data) except DeserializationError as err: - raise_with_traceback(SerializationError, "Unable to build a model: " + str(err), err) + raise SerializationError("Unable to build a model: " + str(err)) from err return self._serialize(data, data_type, **kwargs) @@ -730,6 +725,7 @@ def url(self, name, data, data_type, **kwargs): if kwargs.get("skip_quote") is True: output = str(output) + output = output.replace("{", quote("{")).replace("}", quote("}")) else: output = quote(str(output), safe="") except SerializationError: @@ -744,7 +740,7 @@ def query(self, name, data, data_type, **kwargs): :param str data_type: The type to be serialized from. :keyword bool skip_quote: Whether to skip quote the serialized result. Defaults to False. - :rtype: str + :rtype: str, list :raises: TypeError if serialization fails. :raises: ValueError if data is None """ @@ -753,7 +749,7 @@ def query(self, name, data, data_type, **kwargs): if data_type.startswith("["): internal_data_type = data_type[1:-1] do_quote = not kwargs.get("skip_quote", False) - return str(self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs)) + return self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs) # Not a list, regular serialization output = self.serialize_data(data, data_type, **kwargs) @@ -804,7 +800,7 @@ def serialize_data(self, data, data_type, **kwargs): raise ValueError("No value for given attribute") try: - if data is AzureCoreNull: + if data is CoreNull: return None if data_type in self.basic_types.values(): return self.serialize_basic(data, data_type, **kwargs) @@ -824,7 +820,7 @@ def serialize_data(self, data, data_type, **kwargs): except (ValueError, TypeError) as err: msg = "Unable to serialize value: {!r} as type: {!r}." - raise_with_traceback(SerializationError, msg.format(data, data_type), err) + raise SerializationError(msg.format(data, data_type)) from err else: return self._serialize(data, **kwargs) @@ -993,7 +989,7 @@ def serialize_object(self, attr, **kwargs): return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) if obj_type is _long_type: return self.serialize_long(attr) - if obj_type is unicode_str: + if obj_type is str: return self.serialize_unicode(attr) if obj_type is datetime.datetime: return self.serialize_iso(attr) @@ -1170,10 +1166,10 @@ def serialize_iso(attr, **kwargs): return date + microseconds + "Z" except (ValueError, OverflowError) as err: msg = "Unable to serialize datetime object." - raise_with_traceback(SerializationError, msg, err) + raise SerializationError(msg) from err except AttributeError as err: msg = "ISO-8601 object must be valid Datetime object." - raise_with_traceback(TypeError, msg, err) + raise TypeError(msg) from err @staticmethod def serialize_unix(attr, **kwargs): @@ -1209,7 +1205,6 @@ def rest_key_extractor(attr, attr_desc, data): if working_data is None: # If at any point while following flatten JSON path see None, it means # that all properties under are None as well - # https://github.com/Azure/msrest-for-python/issues/197 return None key = ".".join(dict_keys[1:]) @@ -1230,7 +1225,6 @@ def rest_key_case_insensitive_extractor(attr, attr_desc, data): if working_data is None: # If at any point while following flatten JSON path see None, it means # that all properties under are None as well - # https://github.com/Azure/msrest-for-python/issues/197 return None key = ".".join(dict_keys[1:]) @@ -1371,7 +1365,7 @@ class Deserializer(object): valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): + def __init__(self, classes: Optional[Mapping[str, type]] = None): self.deserialize_type = { "iso-8601": Deserializer.deserialize_iso, "rfc-1123": Deserializer.deserialize_rfc, @@ -1391,7 +1385,7 @@ def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): "duration": (isodate.Duration, datetime.timedelta), "iso-8601": (datetime.datetime), } - self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} + self.dependencies: Dict[str, type] = dict(classes) if classes else {} self.key_extractors = [rest_key_extractor, xml_key_extractor] # Additional properties only works if the "rest_key_extractor" is used to # extract the keys. Making it to work whatever the key extractor is too much @@ -1444,12 +1438,12 @@ def _deserialize(self, target_obj, data): response, class_name = self._classify_target(target_obj, data) - if isinstance(response, basestring): + if isinstance(response, str): return self.deserialize_data(data, response) elif isinstance(response, type) and issubclass(response, Enum): return self.deserialize_enum(data, response) - if data is None: + if data is None or data is CoreNull: return data try: attributes = response._attribute_map # type: ignore @@ -1481,7 +1475,7 @@ def _deserialize(self, target_obj, data): d_attrs[attr] = value except (AttributeError, TypeError, KeyError) as err: msg = "Unable to deserialize to object: " + class_name # type: ignore - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: additional_properties = self._build_additional_properties(attributes, data) return self._instantiate_model(response, d_attrs, additional_properties) @@ -1515,14 +1509,14 @@ def _classify_target(self, target, data): if target is None: return None, None - if isinstance(target, basestring): + if isinstance(target, str): try: target = self.dependencies[target] except KeyError: return target, target try: - target = target._classify(data, self.dependencies) + target = target._classify(data, self.dependencies) # type: ignore except AttributeError: pass # Target is not a Model, no classify return target, target.__class__.__name__ # type: ignore @@ -1578,7 +1572,7 @@ def _unpack_content(raw_data, content_type=None): if hasattr(raw_data, "_content_consumed"): return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) - if isinstance(raw_data, (basestring, bytes)) or hasattr(raw_data, "read"): + if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore return raw_data @@ -1652,7 +1646,7 @@ def deserialize_data(self, data, data_type): except (ValueError, TypeError, AttributeError) as err: msg = "Unable to deserialize response data." msg += " Data: {}, {}".format(data, data_type) - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return self._deserialize(obj_type, data) @@ -1700,7 +1694,7 @@ def deserialize_object(self, attr, **kwargs): if isinstance(attr, ET.Element): # Do no recurse on XML, just return the tree as-is return attr - if isinstance(attr, basestring): + if isinstance(attr, str): return self.deserialize_basic(attr, "str") obj_type = type(attr) if obj_type in self.basic_types: @@ -1757,7 +1751,7 @@ def deserialize_basic(self, attr, data_type): if data_type == "bool": if attr in [True, False, 1, 0]: return bool(attr) - elif isinstance(attr, basestring): + elif isinstance(attr, str): if attr.lower() in ["true", "1"]: return True elif attr.lower() in ["false", "0"]: @@ -1808,7 +1802,6 @@ def deserialize_enum(data, enum_obj): data = data.value if isinstance(data, int): # Workaround. We might consider remove it in the future. - # https://github.com/Azure/azure-rest-api-specs/issues/141 try: return list(enum_obj.__members__.values())[data] except IndexError: @@ -1862,10 +1855,10 @@ def deserialize_decimal(attr): if isinstance(attr, ET.Element): attr = attr.text try: - return decimal.Decimal(attr) # type: ignore + return decimal.Decimal(str(attr)) # type: ignore except decimal.DecimalException as err: msg = "Invalid decimal {}".format(attr) - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err @staticmethod def deserialize_long(attr): @@ -1893,7 +1886,7 @@ def deserialize_duration(attr): duration = isodate.parse_duration(attr) except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize duration object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return duration @@ -1910,7 +1903,7 @@ def deserialize_date(attr): if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore raise DeserializationError("Date must have only digits and -. Received: %s" % attr) # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. - return isodate.parse_date(attr, defaultmonth=None, defaultday=None) + return isodate.parse_date(attr, defaultmonth=0, defaultday=0) @staticmethod def deserialize_time(attr): @@ -1945,7 +1938,7 @@ def deserialize_rfc(attr): date_obj = date_obj.astimezone(tz=TZ_UTC) except ValueError as err: msg = "Cannot deserialize to rfc datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj @@ -1982,7 +1975,7 @@ def deserialize_iso(attr): raise OverflowError("Hit max or min date") except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj @@ -1998,9 +1991,10 @@ def deserialize_unix(attr): if isinstance(attr, ET.Element): attr = int(attr.text) # type: ignore try: + attr = int(attr) date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) except ValueError as err: msg = "Cannot deserialize to unix datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/_vendor.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/_vendor.py deleted file mode 100644 index 0dafe0e287ff..000000000000 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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 diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/_version.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/_version.py index 6640b5be6f60..e5754a47ce68 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/_version.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "8.0.0b3" +VERSION = "1.0.0b1" diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/_azure_stack_hci_client.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/_azure_stack_hci_client.py index 917919a091f8..1bbe13bf1a9d 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/_azure_stack_hci_client.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/_azure_stack_hci_client.py @@ -8,14 +8,22 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +from typing_extensions import Self +from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from .. import models as _models from .._serialization import Deserializer, Serializer from ._configuration import AzureStackHCIClientConfiguration from .operations import ( + ArcSettingsOperations, + ClustersOperations, + DeploymentSettingsOperations, + EdgeDevicesOperations, + ExtensionsOperations, GalleryImagesOperations, GuestAgentOperations, GuestAgentsOperations, @@ -23,8 +31,15 @@ LogicalNetworksOperations, MarketplaceGalleryImagesOperations, NetworkInterfacesOperations, + OffersOperations, Operations, + PublishersOperations, + SecuritySettingsOperations, + SkusOperations, StorageContainersOperations, + UpdateRunsOperations, + UpdateSummariesOperations, + UpdatesOperations, VirtualHardDisksOperations, VirtualMachineInstancesOperations, ) @@ -37,10 +52,19 @@ class AzureStackHCIClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """Azure Stack HCI management service. + :ivar arc_settings: ArcSettingsOperations operations + :vartype arc_settings: azure.mgmt.azurestackhci.aio.operations.ArcSettingsOperations + :ivar clusters: ClustersOperations operations + :vartype clusters: azure.mgmt.azurestackhci.aio.operations.ClustersOperations + :ivar deployment_settings: DeploymentSettingsOperations operations + :vartype deployment_settings: + azure.mgmt.azurestackhci.aio.operations.DeploymentSettingsOperations + :ivar edge_devices: EdgeDevicesOperations operations + :vartype edge_devices: azure.mgmt.azurestackhci.aio.operations.EdgeDevicesOperations + :ivar extensions: ExtensionsOperations operations + :vartype extensions: azure.mgmt.azurestackhci.aio.operations.ExtensionsOperations :ivar gallery_images: GalleryImagesOperations operations :vartype gallery_images: azure.mgmt.azurestackhci.aio.operations.GalleryImagesOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.azurestackhci.aio.operations.Operations :ivar logical_networks: LogicalNetworksOperations operations :vartype logical_networks: azure.mgmt.azurestackhci.aio.operations.LogicalNetworksOperations :ivar marketplace_gallery_images: MarketplaceGalleryImagesOperations operations @@ -49,9 +73,25 @@ class AzureStackHCIClient: # pylint: disable=client-accepts-api-version-keyword :ivar network_interfaces: NetworkInterfacesOperations operations :vartype network_interfaces: azure.mgmt.azurestackhci.aio.operations.NetworkInterfacesOperations + :ivar offers: OffersOperations operations + :vartype offers: azure.mgmt.azurestackhci.aio.operations.OffersOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.azurestackhci.aio.operations.Operations + :ivar publishers: PublishersOperations operations + :vartype publishers: azure.mgmt.azurestackhci.aio.operations.PublishersOperations + :ivar security_settings: SecuritySettingsOperations operations + :vartype security_settings: azure.mgmt.azurestackhci.aio.operations.SecuritySettingsOperations + :ivar skus: SkusOperations operations + :vartype skus: azure.mgmt.azurestackhci.aio.operations.SkusOperations :ivar storage_containers: StorageContainersOperations operations :vartype storage_containers: azure.mgmt.azurestackhci.aio.operations.StorageContainersOperations + :ivar update_runs: UpdateRunsOperations operations + :vartype update_runs: azure.mgmt.azurestackhci.aio.operations.UpdateRunsOperations + :ivar update_summaries: UpdateSummariesOperations operations + :vartype update_summaries: azure.mgmt.azurestackhci.aio.operations.UpdateSummariesOperations + :ivar updates: UpdatesOperations operations + :vartype updates: azure.mgmt.azurestackhci.aio.operations.UpdatesOperations :ivar virtual_hard_disks: VirtualHardDisksOperations operations :vartype virtual_hard_disks: azure.mgmt.azurestackhci.aio.operations.VirtualHardDisksOperations :ivar virtual_machine_instances: VirtualMachineInstancesOperations operations @@ -70,8 +110,8 @@ class AzureStackHCIClient: # pylint: disable=client-accepts-api-version-keyword :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 "2023-09-01-preview". Note that overriding - this default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2024-01-01". Note that overriding this + default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. @@ -87,14 +127,38 @@ def __init__( self._config = AzureStackHCIClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + AsyncARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **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.arc_settings = ArcSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.clusters = ClustersOperations(self._client, self._config, self._serialize, self._deserialize) + self.deployment_settings = DeploymentSettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.edge_devices = EdgeDevicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.extensions = ExtensionsOperations(self._client, self._config, self._serialize, self._deserialize) self.gallery_images = GalleryImagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.logical_networks = LogicalNetworksOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -104,9 +168,21 @@ def __init__( self.network_interfaces = NetworkInterfacesOperations( self._client, self._config, self._serialize, self._deserialize ) + self.offers = OffersOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.publishers = PublishersOperations(self._client, self._config, self._serialize, self._deserialize) + self.security_settings = SecuritySettingsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) self.storage_containers = StorageContainersOperations( self._client, self._config, self._serialize, self._deserialize ) + self.update_runs = UpdateRunsOperations(self._client, self._config, self._serialize, self._deserialize) + self.update_summaries = UpdateSummariesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.updates = UpdatesOperations(self._client, self._config, self._serialize, self._deserialize) self.virtual_hard_disks = VirtualHardDisksOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -119,7 +195,9 @@ def __init__( self.guest_agent = GuestAgentOperations(self._client, self._config, self._serialize, self._deserialize) self.guest_agents = GuestAgentsOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -139,12 +217,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore async def close(self) -> None: await self._client.close() - async def __aenter__(self) -> "AzureStackHCIClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/_configuration.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/_configuration.py index e878a589ebb4..060944bc2c4d 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/_configuration.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/_configuration.py @@ -8,7 +8,6 @@ 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 @@ -19,7 +18,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class AzureStackHCIClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class AzureStackHCIClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for AzureStackHCIClient. Note that all parameters used to create this instance are saved as instance @@ -29,14 +28,13 @@ class AzureStackHCIClientConfiguration(Configuration): # pylint: disable=too-ma :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2023-09-01-preview". Note that overriding - this default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2024-01-01". Note that overriding this + default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(AzureStackHCIClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2023-09-01-preview") + api_version: str = kwargs.pop("api_version", "2024-01-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -48,6 +46,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-azurestackhci/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: 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.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/_patch.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/_patch.py index f99e77fef986..17dbc073e01b 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/_patch.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/_patch.py @@ -25,6 +25,7 @@ # # -------------------------------------------------------------------------- + # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/__init__.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/__init__.py index 1ff6bf5d9fef..2eed2d52b4ab 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/__init__.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/__init__.py @@ -6,12 +6,24 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from ._arc_settings_operations import ArcSettingsOperations +from ._clusters_operations import ClustersOperations +from ._deployment_settings_operations import DeploymentSettingsOperations +from ._edge_devices_operations import EdgeDevicesOperations +from ._extensions_operations import ExtensionsOperations from ._gallery_images_operations import GalleryImagesOperations -from ._operations import Operations from ._logical_networks_operations import LogicalNetworksOperations from ._marketplace_gallery_images_operations import MarketplaceGalleryImagesOperations from ._network_interfaces_operations import NetworkInterfacesOperations +from ._offers_operations import OffersOperations +from ._operations import Operations +from ._publishers_operations import PublishersOperations +from ._security_settings_operations import SecuritySettingsOperations +from ._skus_operations import SkusOperations from ._storage_containers_operations import StorageContainersOperations +from ._update_runs_operations import UpdateRunsOperations +from ._update_summaries_operations import UpdateSummariesOperations +from ._updates_operations import UpdatesOperations from ._virtual_hard_disks_operations import VirtualHardDisksOperations from ._virtual_machine_instances_operations import VirtualMachineInstancesOperations from ._hybrid_identity_metadata_operations import HybridIdentityMetadataOperations @@ -23,12 +35,24 @@ from ._patch import patch_sdk as _patch_sdk __all__ = [ + "ArcSettingsOperations", + "ClustersOperations", + "DeploymentSettingsOperations", + "EdgeDevicesOperations", + "ExtensionsOperations", "GalleryImagesOperations", - "Operations", "LogicalNetworksOperations", "MarketplaceGalleryImagesOperations", "NetworkInterfacesOperations", + "OffersOperations", + "Operations", + "PublishersOperations", + "SecuritySettingsOperations", + "SkusOperations", "StorageContainersOperations", + "UpdateRunsOperations", + "UpdateSummariesOperations", + "UpdatesOperations", "VirtualHardDisksOperations", "VirtualMachineInstancesOperations", "HybridIdentityMetadataOperations", diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_arc_settings_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_arc_settings_operations.py new file mode 100644 index 000000000000..b866e388c4aa --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_arc_settings_operations.py @@ -0,0 +1,980 @@ +# pylint: disable=too-many-lines,too-many-statements +# 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 io import IOBase +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from 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 ...operations._arc_settings_operations import ( + build_consent_and_install_default_extensions_request, + build_create_identity_request, + build_create_request, + build_delete_request, + build_generate_password_request, + build_get_request, + build_initialize_disable_process_request, + build_list_by_cluster_request, + build_update_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ArcSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.azurestackhci.aio.AzureStackHCIClient`'s + :attr:`arc_settings` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_cluster( + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ArcSetting"]: + """Get ArcSetting resources of HCI Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :return: An iterator like instance of either ArcSetting or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.ArcSetting] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ArcSettingList] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_cluster_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ArcSettingList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, resource_group_name: str, cluster_name: str, arc_setting_name: str, **kwargs: Any + ) -> _models.ArcSetting: + """Get ArcSetting resource details of HCI Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting + information. Required. + :type arc_setting_name: str + :return: ArcSetting or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.ArcSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ArcSetting] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + arc_setting_name=arc_setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ArcSetting", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create( + self, + resource_group_name: str, + cluster_name: str, + arc_setting_name: str, + arc_setting: _models.ArcSetting, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ArcSetting: + """Create ArcSetting for HCI cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting + information. Required. + :type arc_setting_name: str + :param arc_setting: Parameters supplied to the Create ArcSetting resource for this HCI cluster. + Required. + :type arc_setting: ~azure.mgmt.azurestackhci.models.ArcSetting + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ArcSetting or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.ArcSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + cluster_name: str, + arc_setting_name: str, + arc_setting: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ArcSetting: + """Create ArcSetting for HCI cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting + information. Required. + :type arc_setting_name: str + :param arc_setting: Parameters supplied to the Create ArcSetting resource for this HCI cluster. + Required. + :type arc_setting: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ArcSetting or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.ArcSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + cluster_name: str, + arc_setting_name: str, + arc_setting: Union[_models.ArcSetting, IO[bytes]], + **kwargs: Any + ) -> _models.ArcSetting: + """Create ArcSetting for HCI cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting + information. Required. + :type arc_setting_name: str + :param arc_setting: Parameters supplied to the Create ArcSetting resource for this HCI cluster. + Is either a ArcSetting type or a IO[bytes] type. Required. + :type arc_setting: ~azure.mgmt.azurestackhci.models.ArcSetting or IO[bytes] + :return: ArcSetting or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.ArcSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ArcSetting] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(arc_setting, (IOBase, bytes)): + _content = arc_setting + else: + _json = self._serialize.body(arc_setting, "ArcSetting") + + _request = build_create_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + arc_setting_name=arc_setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ArcSetting", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + cluster_name: str, + arc_setting_name: str, + arc_setting: _models.ArcSettingsPatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ArcSetting: + """Update ArcSettings for HCI cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting + information. Required. + :type arc_setting_name: str + :param arc_setting: ArcSettings parameters that needs to be updated. Required. + :type arc_setting: ~azure.mgmt.azurestackhci.models.ArcSettingsPatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ArcSetting or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.ArcSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + cluster_name: str, + arc_setting_name: str, + arc_setting: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ArcSetting: + """Update ArcSettings for HCI cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting + information. Required. + :type arc_setting_name: str + :param arc_setting: ArcSettings parameters that needs to be updated. Required. + :type arc_setting: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ArcSetting or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.ArcSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + cluster_name: str, + arc_setting_name: str, + arc_setting: Union[_models.ArcSettingsPatch, IO[bytes]], + **kwargs: Any + ) -> _models.ArcSetting: + """Update ArcSettings for HCI cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting + information. Required. + :type arc_setting_name: str + :param arc_setting: ArcSettings parameters that needs to be updated. Is either a + ArcSettingsPatch type or a IO[bytes] type. Required. + :type arc_setting: ~azure.mgmt.azurestackhci.models.ArcSettingsPatch or IO[bytes] + :return: ArcSetting or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.ArcSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ArcSetting] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(arc_setting, (IOBase, bytes)): + _content = arc_setting + else: + _json = self._serialize.body(arc_setting, "ArcSettingsPatch") + + _request = build_update_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + arc_setting_name=arc_setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ArcSetting", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _delete_initial( + self, resource_group_name: str, cluster_name: str, arc_setting_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + arc_setting_name=arc_setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, cluster_name: str, arc_setting_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete ArcSetting resource details of HCI Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting + information. Required. + :type arc_setting_name: str + :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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + arc_setting_name=arc_setting_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace_async + async def generate_password( + self, resource_group_name: str, cluster_name: str, arc_setting_name: str, **kwargs: Any + ) -> _models.PasswordCredential: + """Generate password for arc settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting + information. Required. + :type arc_setting_name: str + :return: PasswordCredential or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.PasswordCredential + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PasswordCredential] = kwargs.pop("cls", None) + + _request = build_generate_password_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + arc_setting_name=arc_setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PasswordCredential", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_identity_initial( + self, resource_group_name: str, cluster_name: str, arc_setting_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_create_identity_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + arc_setting_name=arc_setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_create_identity( + self, resource_group_name: str, cluster_name: str, arc_setting_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.ArcIdentityResponse]: + """Create Aad identity for arc settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting + information. Required. + :type arc_setting_name: str + :return: An instance of AsyncLROPoller that returns either ArcIdentityResponse or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.ArcIdentityResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ArcIdentityResponse] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_identity_initial( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + arc_setting_name=arc_setting_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ArcIdentityResponse", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ArcIdentityResponse].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ArcIdentityResponse]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace_async + async def consent_and_install_default_extensions( + self, resource_group_name: str, cluster_name: str, arc_setting_name: str, **kwargs: Any + ) -> _models.ArcSetting: + """Add consent time for default extensions and initiate extensions installation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting + information. Required. + :type arc_setting_name: str + :return: ArcSetting or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.ArcSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ArcSetting] = kwargs.pop("cls", None) + + _request = build_consent_and_install_default_extensions_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + arc_setting_name=arc_setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ArcSetting", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _initialize_disable_process_initial( + self, resource_group_name: str, cluster_name: str, arc_setting_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_initialize_disable_process_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + arc_setting_name=arc_setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_initialize_disable_process( + self, resource_group_name: str, cluster_name: str, arc_setting_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Initializes ARC Disable process on the cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting + information. Required. + :type arc_setting_name: str + :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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._initialize_disable_process_initial( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + arc_setting_name=arc_setting_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_clusters_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_clusters_operations.py new file mode 100644 index 000000000000..5debd80903a6 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_clusters_operations.py @@ -0,0 +1,1144 @@ +# pylint: disable=too-many-lines,too-many-statements +# 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 io import IOBase +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from 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 ...operations._clusters_operations import ( + build_create_identity_request, + build_create_request, + build_delete_request, + build_extend_software_assurance_benefit_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_update_request, + build_upload_certificate_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ClustersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.azurestackhci.aio.AzureStackHCIClient`'s + :attr:`clusters` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.Cluster"]: + """List all HCI clusters in a subscription. + + :return: An iterator like instance of either Cluster or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ClusterList] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ClusterList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Cluster"]: + """List all HCI clusters in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of either Cluster or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ClusterList] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ClusterList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> _models.Cluster: + """Get HCI cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :return: Cluster or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.Cluster + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.Cluster] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Cluster", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def create( + self, + resource_group_name: str, + cluster_name: str, + cluster: _models.Cluster, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Cluster: + """Create an HCI cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param cluster: Details of the HCI cluster. Required. + :type cluster: ~azure.mgmt.azurestackhci.models.Cluster + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Cluster or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.Cluster + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + cluster_name: str, + cluster: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Cluster: + """Create an HCI cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param cluster: Details of the HCI cluster. Required. + :type cluster: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: Cluster or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.Cluster + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, resource_group_name: str, cluster_name: str, cluster: Union[_models.Cluster, IO[bytes]], **kwargs: Any + ) -> _models.Cluster: + """Create an HCI cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param cluster: Details of the HCI cluster. Is either a Cluster type or a IO[bytes] type. + Required. + :type cluster: ~azure.mgmt.azurestackhci.models.Cluster or IO[bytes] + :return: Cluster or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.Cluster + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Cluster] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(cluster, (IOBase, bytes)): + _content = cluster + else: + _json = self._serialize.body(cluster, "Cluster") + + _request = build_create_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Cluster", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + cluster_name: str, + cluster: _models.ClusterPatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Cluster: + """Update an HCI cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param cluster: Details of the HCI cluster. Required. + :type cluster: ~azure.mgmt.azurestackhci.models.ClusterPatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Cluster or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.Cluster + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + cluster_name: str, + cluster: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Cluster: + """Update an HCI cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param cluster: Details of the HCI cluster. Required. + :type cluster: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: Cluster or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.Cluster + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + cluster_name: str, + cluster: Union[_models.ClusterPatch, IO[bytes]], + **kwargs: Any + ) -> _models.Cluster: + """Update an HCI cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param cluster: Details of the HCI cluster. Is either a ClusterPatch type or a IO[bytes] type. + Required. + :type cluster: ~azure.mgmt.azurestackhci.models.ClusterPatch or IO[bytes] + :return: Cluster or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.Cluster + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Cluster] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(cluster, (IOBase, bytes)): + _content = cluster + else: + _json = self._serialize.body(cluster, "ClusterPatch") + + _request = build_update_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Cluster", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _delete_initial(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Delete an HCI cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + async def _upload_certificate_initial( + self, + resource_group_name: str, + cluster_name: str, + upload_certificate_request: Union[_models.UploadCertificateRequest, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(upload_certificate_request, (IOBase, bytes)): + _content = upload_certificate_request + else: + _json = self._serialize.body(upload_certificate_request, "UploadCertificateRequest") + + _request = build_upload_certificate_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_upload_certificate( + self, + resource_group_name: str, + cluster_name: str, + upload_certificate_request: _models.UploadCertificateRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Upload certificate. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param upload_certificate_request: Upload certificate request. Required. + :type upload_certificate_request: ~azure.mgmt.azurestackhci.models.UploadCertificateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_upload_certificate( + self, + resource_group_name: str, + cluster_name: str, + upload_certificate_request: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Upload certificate. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param upload_certificate_request: Upload certificate request. Required. + :type upload_certificate_request: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_upload_certificate( + self, + resource_group_name: str, + cluster_name: str, + upload_certificate_request: Union[_models.UploadCertificateRequest, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Upload certificate. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param upload_certificate_request: Upload certificate request. Is either a + UploadCertificateRequest type or a IO[bytes] type. Required. + :type upload_certificate_request: ~azure.mgmt.azurestackhci.models.UploadCertificateRequest or + IO[bytes] + :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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._upload_certificate_initial( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + upload_certificate_request=upload_certificate_request, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + async def _create_identity_initial( + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_create_identity_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_create_identity( + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.ClusterIdentityResponse]: + """Create cluster identity. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :return: An instance of AsyncLROPoller that returns either ClusterIdentityResponse or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.ClusterIdentityResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ClusterIdentityResponse] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_identity_initial( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ClusterIdentityResponse", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ClusterIdentityResponse].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ClusterIdentityResponse]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _extend_software_assurance_benefit_initial( # pylint: disable=name-too-long + self, + resource_group_name: str, + cluster_name: str, + software_assurance_change_request: Union[_models.SoftwareAssuranceChangeRequest, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(software_assurance_change_request, (IOBase, bytes)): + _content = software_assurance_change_request + else: + _json = self._serialize.body(software_assurance_change_request, "SoftwareAssuranceChangeRequest") + + _request = build_extend_software_assurance_benefit_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_extend_software_assurance_benefit( + self, + resource_group_name: str, + cluster_name: str, + software_assurance_change_request: _models.SoftwareAssuranceChangeRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Cluster]: + """Extends Software Assurance Benefit to a cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param software_assurance_change_request: Software Assurance Change Request Payload. Required. + :type software_assurance_change_request: + ~azure.mgmt.azurestackhci.models.SoftwareAssuranceChangeRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either Cluster or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_extend_software_assurance_benefit( + self, + resource_group_name: str, + cluster_name: str, + software_assurance_change_request: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Cluster]: + """Extends Software Assurance Benefit to a cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param software_assurance_change_request: Software Assurance Change Request Payload. Required. + :type software_assurance_change_request: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either Cluster or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_extend_software_assurance_benefit( + self, + resource_group_name: str, + cluster_name: str, + software_assurance_change_request: Union[_models.SoftwareAssuranceChangeRequest, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Cluster]: + """Extends Software Assurance Benefit to a cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param software_assurance_change_request: Software Assurance Change Request Payload. Is either + a SoftwareAssuranceChangeRequest type or a IO[bytes] type. Required. + :type software_assurance_change_request: + ~azure.mgmt.azurestackhci.models.SoftwareAssuranceChangeRequest or IO[bytes] + :return: An instance of AsyncLROPoller that returns either Cluster or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Cluster] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._extend_software_assurance_benefit_initial( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + software_assurance_change_request=software_assurance_change_request, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Cluster", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Cluster].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Cluster]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_deployment_settings_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_deployment_settings_operations.py new file mode 100644 index 000000000000..e833fe03fcc5 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_deployment_settings_operations.py @@ -0,0 +1,542 @@ +# pylint: disable=too-many-lines,too-many-statements +# 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 io import IOBase +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from 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 ...operations._deployment_settings_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_clusters_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class DeploymentSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.azurestackhci.aio.AzureStackHCIClient`'s + :attr:`deployment_settings` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_clusters( + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> AsyncIterable["_models.DeploymentSetting"]: + """List DeploymentSetting resources by Clusters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :return: An iterator like instance of either DeploymentSetting or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.DeploymentSetting] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.DeploymentSettingListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_clusters_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DeploymentSettingListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, resource_group_name: str, cluster_name: str, deployment_settings_name: str = "default", **kwargs: Any + ) -> _models.DeploymentSetting: + """Get a DeploymentSetting. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param deployment_settings_name: Name of Deployment Setting. Default value is "default". + :type deployment_settings_name: str + :return: DeploymentSetting or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.DeploymentSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.DeploymentSetting] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + deployment_settings_name=deployment_settings_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DeploymentSetting", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + cluster_name: str, + resource: Union[_models.DeploymentSetting, IO[bytes]], + deployment_settings_name: str = "default", + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IOBase, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "DeploymentSetting") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + deployment_settings_name=deployment_settings_name, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + cluster_name: str, + resource: _models.DeploymentSetting, + deployment_settings_name: str = "default", + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentSetting]: + """Create a DeploymentSetting. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param resource: Resource create parameters. Required. + :type resource: ~azure.mgmt.azurestackhci.models.DeploymentSetting + :param deployment_settings_name: Name of Deployment Setting. Default value is "default". + :type deployment_settings_name: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either DeploymentSetting or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.DeploymentSetting] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + cluster_name: str, + resource: IO[bytes], + deployment_settings_name: str = "default", + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentSetting]: + """Create a DeploymentSetting. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param resource: Resource create parameters. Required. + :type resource: IO[bytes] + :param deployment_settings_name: Name of Deployment Setting. Default value is "default". + :type deployment_settings_name: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either DeploymentSetting or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.DeploymentSetting] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + cluster_name: str, + resource: Union[_models.DeploymentSetting, IO[bytes]], + deployment_settings_name: str = "default", + **kwargs: Any + ) -> AsyncLROPoller[_models.DeploymentSetting]: + """Create a DeploymentSetting. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param resource: Resource create parameters. Is either a DeploymentSetting type or a IO[bytes] + type. Required. + :type resource: ~azure.mgmt.azurestackhci.models.DeploymentSetting or IO[bytes] + :param deployment_settings_name: Name of Deployment Setting. Default value is "default". + :type deployment_settings_name: str + :return: An instance of AsyncLROPoller that returns either DeploymentSetting or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.DeploymentSetting] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DeploymentSetting] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + resource=resource, + deployment_settings_name=deployment_settings_name, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DeploymentSetting", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.DeploymentSetting].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.DeploymentSetting]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, cluster_name: str, deployment_settings_name: str = "default", **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + deployment_settings_name=deployment_settings_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, cluster_name: str, deployment_settings_name: str = "default", **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete a DeploymentSetting. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param deployment_settings_name: Name of Deployment Setting. Default value is "default". + :type deployment_settings_name: str + :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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + deployment_settings_name=deployment_settings_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_edge_devices_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_edge_devices_operations.py new file mode 100644 index 000000000000..90afd36b683a --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_edge_devices_operations.py @@ -0,0 +1,711 @@ +# pylint: disable=too-many-lines,too-many-statements +# 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 io import IOBase +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from 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 ...operations._edge_devices_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_validate_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class EdgeDevicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.azurestackhci.aio.AzureStackHCIClient`'s + :attr:`edge_devices` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, resource_uri: str, **kwargs: Any) -> AsyncIterable["_models.EdgeDevice"]: + """List EdgeDevice resources by parent. + + :param resource_uri: The fully qualified Azure Resource manager identifier of the resource. + Required. + :type resource_uri: str + :return: An iterator like instance of either EdgeDevice or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.EdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.EdgeDeviceListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_uri=resource_uri, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("EdgeDeviceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get(self, resource_uri: str, edge_device_name: str = "default", **kwargs: Any) -> _models.EdgeDevice: + """Get a EdgeDevice. + + :param resource_uri: The fully qualified Azure Resource manager identifier of the resource. + Required. + :type resource_uri: str + :param edge_device_name: Name of Device. Default value is "default". + :type edge_device_name: str + :return: EdgeDevice or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.EdgeDevice + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.EdgeDevice] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_uri=resource_uri, + edge_device_name=edge_device_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("EdgeDevice", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_uri: str, + resource: Union[_models.EdgeDevice, IO[bytes]], + edge_device_name: str = "default", + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IOBase, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "EdgeDevice") + + _request = build_create_or_update_request( + resource_uri=resource_uri, + edge_device_name=edge_device_name, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_uri: str, + resource: _models.EdgeDevice, + edge_device_name: str = "default", + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.EdgeDevice]: + """Create a EdgeDevice. + + :param resource_uri: The fully qualified Azure Resource manager identifier of the resource. + Required. + :type resource_uri: str + :param resource: Resource create parameters. Required. + :type resource: ~azure.mgmt.azurestackhci.models.EdgeDevice + :param edge_device_name: Name of Device. Default value is "default". + :type edge_device_name: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either EdgeDevice or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.EdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_uri: str, + resource: IO[bytes], + edge_device_name: str = "default", + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.EdgeDevice]: + """Create a EdgeDevice. + + :param resource_uri: The fully qualified Azure Resource manager identifier of the resource. + Required. + :type resource_uri: str + :param resource: Resource create parameters. Required. + :type resource: IO[bytes] + :param edge_device_name: Name of Device. Default value is "default". + :type edge_device_name: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either EdgeDevice or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.EdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_uri: str, + resource: Union[_models.EdgeDevice, IO[bytes]], + edge_device_name: str = "default", + **kwargs: Any + ) -> AsyncLROPoller[_models.EdgeDevice]: + """Create a EdgeDevice. + + :param resource_uri: The fully qualified Azure Resource manager identifier of the resource. + Required. + :type resource_uri: str + :param resource: Resource create parameters. Is either a EdgeDevice type or a IO[bytes] type. + Required. + :type resource: ~azure.mgmt.azurestackhci.models.EdgeDevice or IO[bytes] + :param edge_device_name: Name of Device. Default value is "default". + :type edge_device_name: str + :return: An instance of AsyncLROPoller that returns either EdgeDevice or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.EdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.EdgeDevice] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_uri=resource_uri, + resource=resource, + edge_device_name=edge_device_name, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("EdgeDevice", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.EdgeDevice].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.EdgeDevice]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_uri: str, edge_device_name: str = "default", **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_uri=resource_uri, + edge_device_name=edge_device_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_uri: str, edge_device_name: str = "default", **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete a EdgeDevice. + + :param resource_uri: The fully qualified Azure Resource manager identifier of the resource. + Required. + :type resource_uri: str + :param edge_device_name: Name of Device. Default value is "default". + :type edge_device_name: str + :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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_uri=resource_uri, + edge_device_name=edge_device_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + async def _validate_initial( + self, + resource_uri: str, + validate_request: Union[_models.ValidateRequest, IO[bytes]], + edge_device_name: str = "default", + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(validate_request, (IOBase, bytes)): + _content = validate_request + else: + _json = self._serialize.body(validate_request, "ValidateRequest") + + _request = build_validate_request( + resource_uri=resource_uri, + edge_device_name=edge_device_name, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_validate( + self, + resource_uri: str, + validate_request: _models.ValidateRequest, + edge_device_name: str = "default", + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ValidateResponse]: + """A long-running resource action. + + :param resource_uri: The fully qualified Azure Resource manager identifier of the resource. + Required. + :type resource_uri: str + :param validate_request: The content of the action request. Required. + :type validate_request: ~azure.mgmt.azurestackhci.models.ValidateRequest + :param edge_device_name: Name of Device. Default value is "default". + :type edge_device_name: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either ValidateResponse or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.ValidateResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_validate( + self, + resource_uri: str, + validate_request: IO[bytes], + edge_device_name: str = "default", + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ValidateResponse]: + """A long-running resource action. + + :param resource_uri: The fully qualified Azure Resource manager identifier of the resource. + Required. + :type resource_uri: str + :param validate_request: The content of the action request. Required. + :type validate_request: IO[bytes] + :param edge_device_name: Name of Device. Default value is "default". + :type edge_device_name: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either ValidateResponse or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.ValidateResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_validate( + self, + resource_uri: str, + validate_request: Union[_models.ValidateRequest, IO[bytes]], + edge_device_name: str = "default", + **kwargs: Any + ) -> AsyncLROPoller[_models.ValidateResponse]: + """A long-running resource action. + + :param resource_uri: The fully qualified Azure Resource manager identifier of the resource. + Required. + :type resource_uri: str + :param validate_request: The content of the action request. Is either a ValidateRequest type or + a IO[bytes] type. Required. + :type validate_request: ~azure.mgmt.azurestackhci.models.ValidateRequest or IO[bytes] + :param edge_device_name: Name of Device. Default value is "default". + :type edge_device_name: str + :return: An instance of AsyncLROPoller that returns either ValidateResponse or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.ValidateResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ValidateResponse] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._validate_initial( + resource_uri=resource_uri, + validate_request=validate_request, + edge_device_name=edge_device_name, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ValidateResponse", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.ValidateResponse].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.ValidateResponse]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_extensions_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_extensions_operations.py new file mode 100644 index 000000000000..079c6a6938b5 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_extensions_operations.py @@ -0,0 +1,1005 @@ +# pylint: disable=too-many-lines,too-many-statements +# 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 io import IOBase +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from 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 ...operations._extensions_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_by_arc_setting_request, + build_update_request, + build_upgrade_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.azurestackhci.aio.AzureStackHCIClient`'s + :attr:`extensions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_arc_setting( + self, resource_group_name: str, cluster_name: str, arc_setting_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Extension"]: + """List all Extensions under ArcSetting resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting + information. Required. + :type arc_setting_name: str + :return: An iterator like instance of either Extension or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ExtensionList] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_arc_setting_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + arc_setting_name=arc_setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ExtensionList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, resource_group_name: str, cluster_name: str, arc_setting_name: str, extension_name: str, **kwargs: Any + ) -> _models.Extension: + """Get particular Arc Extension of HCI Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting + information. Required. + :type arc_setting_name: str + :param extension_name: The name of the machine extension. Required. + :type extension_name: str + :return: Extension or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.Extension + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + arc_setting_name=arc_setting_name, + extension_name=extension_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Extension", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_initial( + self, + resource_group_name: str, + cluster_name: str, + arc_setting_name: str, + extension_name: str, + extension: Union[_models.Extension, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(extension, (IOBase, bytes)): + _content = extension + else: + _json = self._serialize.body(extension, "Extension") + + _request = build_create_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + arc_setting_name=arc_setting_name, + extension_name=extension_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create( + self, + resource_group_name: str, + cluster_name: str, + arc_setting_name: str, + extension_name: str, + extension: _models.Extension, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Extension]: + """Create Extension for HCI cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting + information. Required. + :type arc_setting_name: str + :param extension_name: The name of the machine extension. Required. + :type extension_name: str + :param extension: Details of the Machine Extension to be created. Required. + :type extension: ~azure.mgmt.azurestackhci.models.Extension + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either Extension or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + cluster_name: str, + arc_setting_name: str, + extension_name: str, + extension: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Extension]: + """Create Extension for HCI cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting + information. Required. + :type arc_setting_name: str + :param extension_name: The name of the machine extension. Required. + :type extension_name: str + :param extension: Details of the Machine Extension to be created. Required. + :type extension: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either Extension or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + cluster_name: str, + arc_setting_name: str, + extension_name: str, + extension: Union[_models.Extension, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Extension]: + """Create Extension for HCI cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting + information. Required. + :type arc_setting_name: str + :param extension_name: The name of the machine extension. Required. + :type extension_name: str + :param extension: Details of the Machine Extension to be created. Is either a Extension type or + a IO[bytes] type. Required. + :type extension: ~azure.mgmt.azurestackhci.models.Extension or IO[bytes] + :return: An instance of AsyncLROPoller that returns either Extension or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + arc_setting_name=arc_setting_name, + extension_name=extension_name, + extension=extension, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Extension", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Extension].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Extension]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _update_initial( + self, + resource_group_name: str, + cluster_name: str, + arc_setting_name: str, + extension_name: str, + extension: Union[_models.ExtensionPatch, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(extension, (IOBase, bytes)): + _content = extension + else: + _json = self._serialize.body(extension, "ExtensionPatch") + + _request = build_update_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + arc_setting_name=arc_setting_name, + extension_name=extension_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + cluster_name: str, + arc_setting_name: str, + extension_name: str, + extension: _models.ExtensionPatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Extension]: + """Update Extension for HCI cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting + information. Required. + :type arc_setting_name: str + :param extension_name: The name of the machine extension. Required. + :type extension_name: str + :param extension: Details of the Machine Extension to be created. Required. + :type extension: ~azure.mgmt.azurestackhci.models.ExtensionPatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either Extension or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + cluster_name: str, + arc_setting_name: str, + extension_name: str, + extension: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.Extension]: + """Update Extension for HCI cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting + information. Required. + :type arc_setting_name: str + :param extension_name: The name of the machine extension. Required. + :type extension_name: str + :param extension: Details of the Machine Extension to be created. Required. + :type extension: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either Extension or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + cluster_name: str, + arc_setting_name: str, + extension_name: str, + extension: Union[_models.ExtensionPatch, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[_models.Extension]: + """Update Extension for HCI cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting + information. Required. + :type arc_setting_name: str + :param extension_name: The name of the machine extension. Required. + :type extension_name: str + :param extension: Details of the Machine Extension to be created. Is either a ExtensionPatch + type or a IO[bytes] type. Required. + :type extension: ~azure.mgmt.azurestackhci.models.ExtensionPatch or IO[bytes] + :return: An instance of AsyncLROPoller that returns either Extension or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + arc_setting_name=arc_setting_name, + extension_name=extension_name, + extension=extension, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Extension", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "original-uri"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.Extension].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.Extension]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, cluster_name: str, arc_setting_name: str, extension_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + arc_setting_name=arc_setting_name, + extension_name=extension_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, cluster_name: str, arc_setting_name: str, extension_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete particular Arc Extension of HCI Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting + information. Required. + :type arc_setting_name: str + :param extension_name: The name of the machine extension. Required. + :type extension_name: str + :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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + arc_setting_name=arc_setting_name, + extension_name=extension_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + async def _upgrade_initial( + self, + resource_group_name: str, + cluster_name: str, + arc_setting_name: str, + extension_name: str, + extension_upgrade_parameters: Union[_models.ExtensionUpgradeParameters, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(extension_upgrade_parameters, (IOBase, bytes)): + _content = extension_upgrade_parameters + else: + _json = self._serialize.body(extension_upgrade_parameters, "ExtensionUpgradeParameters") + + _request = build_upgrade_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + arc_setting_name=arc_setting_name, + extension_name=extension_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_upgrade( + self, + resource_group_name: str, + cluster_name: str, + arc_setting_name: str, + extension_name: str, + extension_upgrade_parameters: _models.ExtensionUpgradeParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Upgrade a particular Arc Extension of HCI Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting + information. Required. + :type arc_setting_name: str + :param extension_name: The name of the machine extension. Required. + :type extension_name: str + :param extension_upgrade_parameters: Parameters supplied to the Upgrade Extensions operation. + Required. + :type extension_upgrade_parameters: ~azure.mgmt.azurestackhci.models.ExtensionUpgradeParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_upgrade( + self, + resource_group_name: str, + cluster_name: str, + arc_setting_name: str, + extension_name: str, + extension_upgrade_parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Upgrade a particular Arc Extension of HCI Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting + information. Required. + :type arc_setting_name: str + :param extension_name: The name of the machine extension. Required. + :type extension_name: str + :param extension_upgrade_parameters: Parameters supplied to the Upgrade Extensions operation. + Required. + :type extension_upgrade_parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_upgrade( + self, + resource_group_name: str, + cluster_name: str, + arc_setting_name: str, + extension_name: str, + extension_upgrade_parameters: Union[_models.ExtensionUpgradeParameters, IO[bytes]], + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Upgrade a particular Arc Extension of HCI Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting + information. Required. + :type arc_setting_name: str + :param extension_name: The name of the machine extension. Required. + :type extension_name: str + :param extension_upgrade_parameters: Parameters supplied to the Upgrade Extensions operation. + Is either a ExtensionUpgradeParameters type or a IO[bytes] type. Required. + :type extension_upgrade_parameters: ~azure.mgmt.azurestackhci.models.ExtensionUpgradeParameters + or IO[bytes] + :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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._upgrade_initial( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + arc_setting_name=arc_setting_name, + extension_name=extension_name, + extension_upgrade_parameters=extension_upgrade_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_gallery_images_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_gallery_images_operations.py index 154f80239ef6..96ba972b33c7 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_gallery_images_operations.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_gallery_images_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, 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.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._gallery_images_operations import ( build_create_or_update_request, build_delete_request, @@ -40,6 +41,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -72,12 +77,11 @@ async def get(self, resource_group_name: str, gallery_image_name: str, **kwargs: :type resource_group_name: str :param gallery_image_name: Name of the gallery image. Required. :type gallery_image_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: GalleryImages or the result of cls(response) :rtype: ~azure.mgmt.azurestackhci.models.GalleryImages :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -91,21 +95,19 @@ async def get(self, resource_group_name: str, gallery_image_name: str, **kwargs: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.GalleryImages] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, gallery_image_name=gallery_image_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -115,25 +117,21 @@ async def get(self, resource_group_name: str, gallery_image_name: str, **kwargs: error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("GalleryImages", pipeline_response) + deserialized = self._deserialize("GalleryImages", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/galleryImages/{galleryImageName}" - } + return deserialized # type: ignore async def _create_or_update_initial( self, resource_group_name: str, gallery_image_name: str, - gallery_images: Union[_models.GalleryImages, IO], + gallery_images: Union[_models.GalleryImages, IO[bytes]], **kwargs: Any - ) -> _models.GalleryImages: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -146,7 +144,7 @@ async def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.GalleryImages] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -156,7 +154,7 @@ async def _create_or_update_initial( else: _json = self._serialize.body(gallery_images, "GalleryImages") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, gallery_image_name=gallery_image_name, subscription_id=self._config.subscription_id, @@ -164,40 +162,35 @@ async def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("GalleryImages", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("GalleryImages", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/galleryImages/{galleryImageName}" - } - @overload async def begin_create_or_update( self, @@ -221,14 +214,6 @@ async def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either GalleryImages or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.GalleryImages] @@ -240,7 +225,7 @@ async def begin_create_or_update( self, resource_group_name: str, gallery_image_name: str, - gallery_images: IO, + gallery_images: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -254,18 +239,10 @@ async def begin_create_or_update( :param gallery_image_name: Name of the gallery image. Required. :type gallery_image_name: str :param gallery_images: Required. - :type gallery_images: IO + :type gallery_images: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either GalleryImages or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.GalleryImages] @@ -277,7 +254,7 @@ async def begin_create_or_update( self, resource_group_name: str, gallery_image_name: str, - gallery_images: Union[_models.GalleryImages, IO], + gallery_images: Union[_models.GalleryImages, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.GalleryImages]: """The operation to create or update a gallery image. Please note some properties can be set only @@ -288,19 +265,8 @@ async def begin_create_or_update( :type resource_group_name: str :param gallery_image_name: Name of the gallery image. Required. :type gallery_image_name: str - :param gallery_images: Is either a GalleryImages type or a IO type. Required. - :type gallery_images: ~azure.mgmt.azurestackhci.models.GalleryImages or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param gallery_images: Is either a GalleryImages type or a IO[bytes] type. Required. + :type gallery_images: ~azure.mgmt.azurestackhci.models.GalleryImages or IO[bytes] :return: An instance of AsyncLROPoller that returns either GalleryImages or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.GalleryImages] @@ -327,12 +293,13 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("GalleryImages", pipeline_response) + deserialized = self._deserialize("GalleryImages", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -345,22 +312,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.GalleryImages].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/galleryImages/{galleryImageName}" - } + return AsyncLROPoller[_models.GalleryImages]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, gallery_image_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -372,28 +337,31 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, gallery_image_name=gallery_image_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) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -402,12 +370,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/galleryImages/{galleryImageName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -420,14 +388,6 @@ async def begin_delete( :type resource_group_name: str :param gallery_image_name: Name of the gallery image. Required. :type gallery_image_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: @@ -441,7 +401,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, gallery_image_name=gallery_image_name, api_version=api_version, @@ -450,11 +410,12 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -466,26 +427,22 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/galleryImages/{galleryImageName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _update_initial( self, resource_group_name: str, gallery_image_name: str, - gallery_images: Union[_models.GalleryImagesUpdateRequest, IO], + gallery_images: Union[_models.GalleryImagesUpdateRequest, IO[bytes]], **kwargs: Any - ) -> Optional[_models.GalleryImages]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -498,7 +455,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.GalleryImages]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -508,7 +465,7 @@ async def _update_initial( else: _json = self._serialize.body(gallery_images, "GalleryImagesUpdateRequest") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, gallery_image_name=gallery_image_name, subscription_id=self._config.subscription_id, @@ -516,41 +473,38 @@ async def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("GalleryImages", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/galleryImages/{galleryImageName}" - } + return deserialized # type: ignore @overload async def begin_update( @@ -574,14 +528,6 @@ async def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either GalleryImages or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.GalleryImages] @@ -593,7 +539,7 @@ async def begin_update( self, resource_group_name: str, gallery_image_name: str, - gallery_images: IO, + gallery_images: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -606,18 +552,10 @@ async def begin_update( :param gallery_image_name: Name of the gallery image. Required. :type gallery_image_name: str :param gallery_images: Required. - :type gallery_images: IO + :type gallery_images: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either GalleryImages or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.GalleryImages] @@ -629,7 +567,7 @@ async def begin_update( self, resource_group_name: str, gallery_image_name: str, - gallery_images: Union[_models.GalleryImagesUpdateRequest, IO], + gallery_images: Union[_models.GalleryImagesUpdateRequest, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.GalleryImages]: """The operation to update a gallery image. @@ -639,19 +577,9 @@ async def begin_update( :type resource_group_name: str :param gallery_image_name: Name of the gallery image. Required. :type gallery_image_name: str - :param gallery_images: Is either a GalleryImagesUpdateRequest type or a IO type. Required. - :type gallery_images: ~azure.mgmt.azurestackhci.models.GalleryImagesUpdateRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param gallery_images: Is either a GalleryImagesUpdateRequest type or a IO[bytes] type. + Required. + :type gallery_images: ~azure.mgmt.azurestackhci.models.GalleryImagesUpdateRequest or IO[bytes] :return: An instance of AsyncLROPoller that returns either GalleryImages or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.GalleryImages] @@ -678,12 +606,13 @@ async def begin_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("GalleryImages", pipeline_response) + deserialized = self._deserialize("GalleryImages", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -696,17 +625,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.GalleryImages].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/galleryImages/{galleryImageName}" - } + return AsyncLROPoller[_models.GalleryImages]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.GalleryImages"]: @@ -716,7 +643,6 @@ def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_model :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either GalleryImages or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.GalleryImages] :raises ~azure.core.exceptions.HttpResponseError: @@ -727,7 +653,7 @@ def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_model api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.GalleryImagesListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -738,16 +664,14 @@ def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_model def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -759,13 +683,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("GalleryImagesListResult", pipeline_response) @@ -775,11 +698,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -792,16 +715,11 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/galleryImages" - } - @distributed_trace def list_all(self, **kwargs: Any) -> AsyncIterable["_models.GalleryImages"]: """Lists all of the gallery images in the specified subscription. Use the nextLink property in the response to get the next page of gallery images. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either GalleryImages or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.GalleryImages] :raises ~azure.core.exceptions.HttpResponseError: @@ -812,7 +730,7 @@ def list_all(self, **kwargs: Any) -> AsyncIterable["_models.GalleryImages"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.GalleryImagesListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -823,15 +741,13 @@ def list_all(self, **kwargs: Any) -> AsyncIterable["_models.GalleryImages"]: def prepare_request(next_link=None): if not next_link: - request = build_list_all_request( + _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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -843,13 +759,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("GalleryImagesListResult", pipeline_response) @@ -859,11 +774,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -875,5 +790,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_all.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/galleryImages"} diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_guest_agent_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_guest_agent_operations.py index 74de4d89d7cb..3a2de5d93bb3 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_guest_agent_operations.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_guest_agent_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -15,21 +16,25 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, 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.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._guest_agent_operations import build_create_request, build_delete_request, build_get_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -54,9 +59,9 @@ def __init__(self, *args, **kwargs) -> None: self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") async def _create_initial( - self, resource_uri: str, body: Optional[Union[_models.GuestAgent, IO]] = None, **kwargs: Any - ) -> _models.GuestAgent: - error_map = { + self, resource_uri: str, body: Optional[Union[_models.GuestAgent, IO[bytes]]] = None, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -69,7 +74,7 @@ async def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.GuestAgent] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -82,46 +87,41 @@ async def _create_initial( else: _json = None - request = build_create_request( + _request = build_create_request( resource_uri=resource_uri, api_version=api_version, content_type=content_type, json=_json, content=_content, - 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("GuestAgent", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("GuestAgent", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_initial.metadata = { - "url": "/{resourceUri}/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default/guestAgents/default" - } - @overload async def begin_create( self, @@ -143,14 +143,6 @@ async def begin_create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either GuestAgent or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.GuestAgent] @@ -159,7 +151,12 @@ async def begin_create( @overload async def begin_create( - self, resource_uri: str, body: Optional[IO] = None, *, content_type: str = "application/json", **kwargs: Any + self, + resource_uri: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any ) -> AsyncLROPoller[_models.GuestAgent]: """Implements GuestAgent PUT method. @@ -169,18 +166,10 @@ async def begin_create( Compute machine resource to be extended. Required. :type resource_uri: str :param body: Request payload. Default value is None. - :type body: IO + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either GuestAgent or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.GuestAgent] @@ -189,7 +178,7 @@ async def begin_create( @distributed_trace_async async def begin_create( - self, resource_uri: str, body: Optional[Union[_models.GuestAgent, IO]] = None, **kwargs: Any + self, resource_uri: str, body: Optional[Union[_models.GuestAgent, IO[bytes]]] = None, **kwargs: Any ) -> AsyncLROPoller[_models.GuestAgent]: """Implements GuestAgent PUT method. @@ -198,19 +187,9 @@ async def begin_create( :param resource_uri: The fully qualified Azure Resource manager identifier of the Hybrid Compute machine resource to be extended. Required. :type resource_uri: str - :param body: Request payload. Is either a GuestAgent type or a IO type. Default value is None. - :type body: ~azure.mgmt.azurestackhci.models.GuestAgent or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param body: Request payload. Is either a GuestAgent type or a IO[bytes] type. Default value is + None. + :type body: ~azure.mgmt.azurestackhci.models.GuestAgent or IO[bytes] :return: An instance of AsyncLROPoller that returns either GuestAgent or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.GuestAgent] @@ -236,12 +215,13 @@ async def begin_create( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("GuestAgent", pipeline_response) + deserialized = self._deserialize("GuestAgent", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -254,17 +234,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.GuestAgent].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create.metadata = { - "url": "/{resourceUri}/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default/guestAgents/default" - } + return AsyncLROPoller[_models.GuestAgent]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async async def get(self, resource_uri: str, **kwargs: Any) -> _models.GuestAgent: @@ -275,12 +253,11 @@ async def get(self, resource_uri: str, **kwargs: Any) -> _models.GuestAgent: :param resource_uri: The fully qualified Azure Resource manager identifier of the Hybrid Compute machine resource to be extended. Required. :type resource_uri: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: GuestAgent or the result of cls(response) :rtype: ~azure.mgmt.azurestackhci.models.GuestAgent :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -294,19 +271,17 @@ async def get(self, resource_uri: str, **kwargs: Any) -> _models.GuestAgent: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.GuestAgent] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_uri=resource_uri, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -316,21 +291,15 @@ async def get(self, resource_uri: str, **kwargs: Any) -> _models.GuestAgent: error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("GuestAgent", pipeline_response) + deserialized = self._deserialize("GuestAgent", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/{resourceUri}/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default/guestAgents/default" - } + return deserialized # type: ignore - async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_uri: str, **kwargs: Any - ) -> None: - error_map = { + async def _delete_initial(self, resource_uri: str, **kwargs: Any) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -342,26 +311,29 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_uri=resource_uri, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -370,12 +342,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/{resourceUri}/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default/guestAgents/default" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete(self, resource_uri: str, **kwargs: Any) -> AsyncLROPoller[None]: @@ -386,14 +358,6 @@ async def begin_delete(self, resource_uri: str, **kwargs: Any) -> AsyncLROPoller :param resource_uri: The fully qualified Azure Resource manager identifier of the Hybrid Compute machine resource to be extended. Required. :type resource_uri: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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: @@ -407,7 +371,7 @@ async def begin_delete(self, resource_uri: str, **kwargs: Any) -> AsyncLROPoller lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_uri=resource_uri, api_version=api_version, cls=lambda x, y, z: x, @@ -415,11 +379,12 @@ async def begin_delete(self, resource_uri: str, **kwargs: Any) -> AsyncLROPoller params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -428,14 +393,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/{resourceUri}/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default/guestAgents/default" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_guest_agents_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_guest_agents_operations.py index 76a6f5d20ac4..fda7cf005580 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_guest_agents_operations.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_guest_agents_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,16 +20,18 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._guest_agents_operations import build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -61,7 +64,6 @@ def list(self, resource_uri: str, **kwargs: Any) -> AsyncIterable["_models.Guest :param resource_uri: The fully qualified Azure Resource manager identifier of the Hybrid Compute machine resource to be extended. Required. :type resource_uri: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either GuestAgent or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.GuestAgent] :raises ~azure.core.exceptions.HttpResponseError: @@ -72,7 +74,7 @@ def list(self, resource_uri: str, **kwargs: Any) -> AsyncIterable["_models.Guest api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.GuestAgentList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -83,15 +85,13 @@ def list(self, resource_uri: str, **kwargs: Any) -> AsyncIterable["_models.Guest def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_uri=resource_uri, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -103,13 +103,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("GuestAgentList", pipeline_response) @@ -119,11 +118,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -135,7 +134,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/{resourceUri}/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default/guestAgents" - } diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_hybrid_identity_metadata_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_hybrid_identity_metadata_operations.py index 112a061c08d7..27a3a0dfdbf8 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_hybrid_identity_metadata_operations.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_hybrid_identity_metadata_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -19,17 +20,19 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async 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._hybrid_identity_metadata_operations import build_get_request, build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -62,12 +65,11 @@ async def get(self, resource_uri: str, **kwargs: Any) -> _models.HybridIdentityM :param resource_uri: The fully qualified Azure Resource manager identifier of the Hybrid Compute machine resource to be extended. Required. :type resource_uri: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: HybridIdentityMetadata or the result of cls(response) :rtype: ~azure.mgmt.azurestackhci.models.HybridIdentityMetadata :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -81,19 +83,17 @@ async def get(self, resource_uri: str, **kwargs: Any) -> _models.HybridIdentityM api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.HybridIdentityMetadata] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_uri=resource_uri, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -103,16 +103,12 @@ async def get(self, resource_uri: str, **kwargs: Any) -> _models.HybridIdentityM error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("HybridIdentityMetadata", pipeline_response) + deserialized = self._deserialize("HybridIdentityMetadata", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/{resourceUri}/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default/hybridIdentityMetadata/default" - } + return deserialized # type: ignore @distributed_trace def list(self, resource_uri: str, **kwargs: Any) -> AsyncIterable["_models.HybridIdentityMetadata"]: @@ -123,7 +119,6 @@ def list(self, resource_uri: str, **kwargs: Any) -> AsyncIterable["_models.Hybri :param resource_uri: The fully qualified Azure Resource manager identifier of the Hybrid Compute machine resource to be extended. Required. :type resource_uri: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either HybridIdentityMetadata or the result of cls(response) :rtype: @@ -136,7 +131,7 @@ def list(self, resource_uri: str, **kwargs: Any) -> AsyncIterable["_models.Hybri api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.HybridIdentityMetadataList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -147,15 +142,13 @@ def list(self, resource_uri: str, **kwargs: Any) -> AsyncIterable["_models.Hybri def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_uri=resource_uri, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -167,13 +160,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("HybridIdentityMetadataList", pipeline_response) @@ -183,11 +175,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -199,7 +191,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/{resourceUri}/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default/hybridIdentityMetadata" - } diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_logical_networks_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_logical_networks_operations.py index 3f8c87d72e83..609ad1e84088 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_logical_networks_operations.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_logical_networks_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, 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.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._logical_networks_operations import ( build_create_or_update_request, build_delete_request, @@ -40,6 +41,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -72,12 +77,11 @@ async def get(self, resource_group_name: str, logical_network_name: str, **kwarg :type resource_group_name: str :param logical_network_name: Name of the logical network. Required. :type logical_network_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: LogicalNetworks or the result of cls(response) :rtype: ~azure.mgmt.azurestackhci.models.LogicalNetworks :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -91,21 +95,19 @@ async def get(self, resource_group_name: str, logical_network_name: str, **kwarg api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.LogicalNetworks] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, logical_network_name=logical_network_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -115,25 +117,21 @@ async def get(self, resource_group_name: str, logical_network_name: str, **kwarg error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("LogicalNetworks", pipeline_response) + deserialized = self._deserialize("LogicalNetworks", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/logicalNetworks/{logicalNetworkName}" - } + return deserialized # type: ignore async def _create_or_update_initial( self, resource_group_name: str, logical_network_name: str, - logical_networks: Union[_models.LogicalNetworks, IO], + logical_networks: Union[_models.LogicalNetworks, IO[bytes]], **kwargs: Any - ) -> _models.LogicalNetworks: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -146,7 +144,7 @@ async def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.LogicalNetworks] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -156,7 +154,7 @@ async def _create_or_update_initial( else: _json = self._serialize.body(logical_networks, "LogicalNetworks") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, logical_network_name=logical_network_name, subscription_id=self._config.subscription_id, @@ -164,40 +162,35 @@ async def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("LogicalNetworks", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("LogicalNetworks", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/logicalNetworks/{logicalNetworkName}" - } - @overload async def begin_create_or_update( self, @@ -221,14 +214,6 @@ async def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either LogicalNetworks or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.LogicalNetworks] @@ -240,7 +225,7 @@ async def begin_create_or_update( self, resource_group_name: str, logical_network_name: str, - logical_networks: IO, + logical_networks: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -254,18 +239,10 @@ async def begin_create_or_update( :param logical_network_name: Name of the logical network. Required. :type logical_network_name: str :param logical_networks: Required. - :type logical_networks: IO + :type logical_networks: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either LogicalNetworks or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.LogicalNetworks] @@ -277,7 +254,7 @@ async def begin_create_or_update( self, resource_group_name: str, logical_network_name: str, - logical_networks: Union[_models.LogicalNetworks, IO], + logical_networks: Union[_models.LogicalNetworks, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.LogicalNetworks]: """The operation to create or update a logical network. Please note some properties can be set @@ -288,19 +265,8 @@ async def begin_create_or_update( :type resource_group_name: str :param logical_network_name: Name of the logical network. Required. :type logical_network_name: str - :param logical_networks: Is either a LogicalNetworks type or a IO type. Required. - :type logical_networks: ~azure.mgmt.azurestackhci.models.LogicalNetworks or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param logical_networks: Is either a LogicalNetworks type or a IO[bytes] type. Required. + :type logical_networks: ~azure.mgmt.azurestackhci.models.LogicalNetworks or IO[bytes] :return: An instance of AsyncLROPoller that returns either LogicalNetworks or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.LogicalNetworks] @@ -327,12 +293,13 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("LogicalNetworks", pipeline_response) + deserialized = self._deserialize("LogicalNetworks", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -345,22 +312,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.LogicalNetworks].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/logicalNetworks/{logicalNetworkName}" - } + return AsyncLROPoller[_models.LogicalNetworks]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, logical_network_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -372,28 +337,31 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, logical_network_name=logical_network_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) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -402,12 +370,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/logicalNetworks/{logicalNetworkName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -420,14 +388,6 @@ async def begin_delete( :type resource_group_name: str :param logical_network_name: Name of the logical network. Required. :type logical_network_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: @@ -441,7 +401,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, logical_network_name=logical_network_name, api_version=api_version, @@ -450,11 +410,12 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -466,26 +427,22 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/logicalNetworks/{logicalNetworkName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _update_initial( self, resource_group_name: str, logical_network_name: str, - logical_networks: Union[_models.LogicalNetworksUpdateRequest, IO], + logical_networks: Union[_models.LogicalNetworksUpdateRequest, IO[bytes]], **kwargs: Any - ) -> Optional[_models.LogicalNetworks]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -498,7 +455,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.LogicalNetworks]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -508,7 +465,7 @@ async def _update_initial( else: _json = self._serialize.body(logical_networks, "LogicalNetworksUpdateRequest") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, logical_network_name=logical_network_name, subscription_id=self._config.subscription_id, @@ -516,41 +473,38 @@ async def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("LogicalNetworks", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/logicalNetworks/{logicalNetworkName}" - } + return deserialized # type: ignore @overload async def begin_update( @@ -574,14 +528,6 @@ async def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either LogicalNetworks or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.LogicalNetworks] @@ -593,7 +539,7 @@ async def begin_update( self, resource_group_name: str, logical_network_name: str, - logical_networks: IO, + logical_networks: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -606,18 +552,10 @@ async def begin_update( :param logical_network_name: Name of the logical network. Required. :type logical_network_name: str :param logical_networks: Required. - :type logical_networks: IO + :type logical_networks: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either LogicalNetworks or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.LogicalNetworks] @@ -629,7 +567,7 @@ async def begin_update( self, resource_group_name: str, logical_network_name: str, - logical_networks: Union[_models.LogicalNetworksUpdateRequest, IO], + logical_networks: Union[_models.LogicalNetworksUpdateRequest, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.LogicalNetworks]: """The operation to update a logical network. @@ -639,19 +577,10 @@ async def begin_update( :type resource_group_name: str :param logical_network_name: Name of the logical network. Required. :type logical_network_name: str - :param logical_networks: Is either a LogicalNetworksUpdateRequest type or a IO type. Required. - :type logical_networks: ~azure.mgmt.azurestackhci.models.LogicalNetworksUpdateRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param logical_networks: Is either a LogicalNetworksUpdateRequest type or a IO[bytes] type. + Required. + :type logical_networks: ~azure.mgmt.azurestackhci.models.LogicalNetworksUpdateRequest or + IO[bytes] :return: An instance of AsyncLROPoller that returns either LogicalNetworks or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.LogicalNetworks] @@ -678,12 +607,13 @@ async def begin_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("LogicalNetworks", pipeline_response) + deserialized = self._deserialize("LogicalNetworks", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -696,17 +626,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.LogicalNetworks].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/logicalNetworks/{logicalNetworkName}" - } + return AsyncLROPoller[_models.LogicalNetworks]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.LogicalNetworks"]: @@ -716,7 +644,6 @@ def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_model :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either LogicalNetworks or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.LogicalNetworks] @@ -728,7 +655,7 @@ def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_model api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.LogicalNetworksListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -739,16 +666,14 @@ def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_model def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -760,13 +685,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("LogicalNetworksListResult", pipeline_response) @@ -776,11 +700,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -793,16 +717,11 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/logicalNetworks" - } - @distributed_trace def list_all(self, **kwargs: Any) -> AsyncIterable["_models.LogicalNetworks"]: """Lists all of the logical networks in the specified subscription. Use the nextLink property in the response to get the next page of logical networks. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either LogicalNetworks or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.LogicalNetworks] @@ -814,7 +733,7 @@ def list_all(self, **kwargs: Any) -> AsyncIterable["_models.LogicalNetworks"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.LogicalNetworksListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -825,15 +744,13 @@ def list_all(self, **kwargs: Any) -> AsyncIterable["_models.LogicalNetworks"]: def prepare_request(next_link=None): if not next_link: - request = build_list_all_request( + _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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -845,13 +762,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("LogicalNetworksListResult", pipeline_response) @@ -861,11 +777,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -877,5 +793,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_all.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/logicalNetworks"} diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_marketplace_gallery_images_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_marketplace_gallery_images_operations.py index 1511ec6826de..e43c27009da9 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_marketplace_gallery_images_operations.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_marketplace_gallery_images_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, 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.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._marketplace_gallery_images_operations import ( build_create_or_update_request, build_delete_request, @@ -40,6 +41,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -74,12 +79,11 @@ async def get( :type resource_group_name: str :param marketplace_gallery_image_name: Name of the marketplace gallery image. Required. :type marketplace_gallery_image_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: MarketplaceGalleryImages or the result of cls(response) :rtype: ~azure.mgmt.azurestackhci.models.MarketplaceGalleryImages :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -93,21 +97,19 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.MarketplaceGalleryImages] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, marketplace_gallery_image_name=marketplace_gallery_image_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -117,25 +119,21 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("MarketplaceGalleryImages", pipeline_response) + deserialized = self._deserialize("MarketplaceGalleryImages", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/marketplaceGalleryImages/{marketplaceGalleryImageName}" - } + return deserialized # type: ignore async def _create_or_update_initial( self, resource_group_name: str, marketplace_gallery_image_name: str, - marketplace_gallery_images: Union[_models.MarketplaceGalleryImages, IO], + marketplace_gallery_images: Union[_models.MarketplaceGalleryImages, IO[bytes]], **kwargs: Any - ) -> _models.MarketplaceGalleryImages: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -148,7 +146,7 @@ async def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.MarketplaceGalleryImages] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -158,7 +156,7 @@ async def _create_or_update_initial( else: _json = self._serialize.body(marketplace_gallery_images, "MarketplaceGalleryImages") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, marketplace_gallery_image_name=marketplace_gallery_image_name, subscription_id=self._config.subscription_id, @@ -166,40 +164,35 @@ async def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("MarketplaceGalleryImages", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("MarketplaceGalleryImages", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/marketplaceGalleryImages/{marketplaceGalleryImageName}" - } - @overload async def begin_create_or_update( self, @@ -223,14 +216,6 @@ async def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either MarketplaceGalleryImages or the result of cls(response) :rtype: @@ -243,7 +228,7 @@ async def begin_create_or_update( self, resource_group_name: str, marketplace_gallery_image_name: str, - marketplace_gallery_images: IO, + marketplace_gallery_images: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -257,18 +242,10 @@ async def begin_create_or_update( :param marketplace_gallery_image_name: Name of the marketplace gallery image. Required. :type marketplace_gallery_image_name: str :param marketplace_gallery_images: Required. - :type marketplace_gallery_images: IO + :type marketplace_gallery_images: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either MarketplaceGalleryImages or the result of cls(response) :rtype: @@ -281,7 +258,7 @@ async def begin_create_or_update( self, resource_group_name: str, marketplace_gallery_image_name: str, - marketplace_gallery_images: Union[_models.MarketplaceGalleryImages, IO], + marketplace_gallery_images: Union[_models.MarketplaceGalleryImages, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.MarketplaceGalleryImages]: """The operation to create or update a marketplace gallery image. Please note some properties can @@ -292,21 +269,10 @@ async def begin_create_or_update( :type resource_group_name: str :param marketplace_gallery_image_name: Name of the marketplace gallery image. Required. :type marketplace_gallery_image_name: str - :param marketplace_gallery_images: Is either a MarketplaceGalleryImages type or a IO type. - Required. + :param marketplace_gallery_images: Is either a MarketplaceGalleryImages type or a IO[bytes] + type. Required. :type marketplace_gallery_images: ~azure.mgmt.azurestackhci.models.MarketplaceGalleryImages or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + IO[bytes] :return: An instance of AsyncLROPoller that returns either MarketplaceGalleryImages or the result of cls(response) :rtype: @@ -334,12 +300,13 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("MarketplaceGalleryImages", pipeline_response) + deserialized = self._deserialize("MarketplaceGalleryImages", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -352,22 +319,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.MarketplaceGalleryImages].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/marketplaceGalleryImages/{marketplaceGalleryImageName}" - } + return AsyncLROPoller[_models.MarketplaceGalleryImages]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, marketplace_gallery_image_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -379,28 +344,31 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, marketplace_gallery_image_name=marketplace_gallery_image_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) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -409,12 +377,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/marketplaceGalleryImages/{marketplaceGalleryImageName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -427,14 +395,6 @@ async def begin_delete( :type resource_group_name: str :param marketplace_gallery_image_name: Name of the marketplace gallery image. Required. :type marketplace_gallery_image_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: @@ -448,7 +408,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, marketplace_gallery_image_name=marketplace_gallery_image_name, api_version=api_version, @@ -457,11 +417,12 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -473,26 +434,22 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/marketplaceGalleryImages/{marketplaceGalleryImageName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _update_initial( self, resource_group_name: str, marketplace_gallery_image_name: str, - marketplace_gallery_images: Union[_models.MarketplaceGalleryImagesUpdateRequest, IO], + marketplace_gallery_images: Union[_models.MarketplaceGalleryImagesUpdateRequest, IO[bytes]], **kwargs: Any - ) -> Optional[_models.MarketplaceGalleryImages]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -505,7 +462,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.MarketplaceGalleryImages]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -515,7 +472,7 @@ async def _update_initial( else: _json = self._serialize.body(marketplace_gallery_images, "MarketplaceGalleryImagesUpdateRequest") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, marketplace_gallery_image_name=marketplace_gallery_image_name, subscription_id=self._config.subscription_id, @@ -523,41 +480,38 @@ async def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("MarketplaceGalleryImages", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/marketplaceGalleryImages/{marketplaceGalleryImageName}" - } + return deserialized # type: ignore @overload async def begin_update( @@ -582,14 +536,6 @@ async def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either MarketplaceGalleryImages or the result of cls(response) :rtype: @@ -602,7 +548,7 @@ async def begin_update( self, resource_group_name: str, marketplace_gallery_image_name: str, - marketplace_gallery_images: IO, + marketplace_gallery_images: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -615,18 +561,10 @@ async def begin_update( :param marketplace_gallery_image_name: Name of the marketplace gallery image. Required. :type marketplace_gallery_image_name: str :param marketplace_gallery_images: Required. - :type marketplace_gallery_images: IO + :type marketplace_gallery_images: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either MarketplaceGalleryImages or the result of cls(response) :rtype: @@ -639,7 +577,7 @@ async def begin_update( self, resource_group_name: str, marketplace_gallery_image_name: str, - marketplace_gallery_images: Union[_models.MarketplaceGalleryImagesUpdateRequest, IO], + marketplace_gallery_images: Union[_models.MarketplaceGalleryImagesUpdateRequest, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.MarketplaceGalleryImages]: """The operation to update a marketplace gallery image. @@ -650,20 +588,9 @@ async def begin_update( :param marketplace_gallery_image_name: Name of the marketplace gallery image. Required. :type marketplace_gallery_image_name: str :param marketplace_gallery_images: Is either a MarketplaceGalleryImagesUpdateRequest type or a - IO type. Required. + IO[bytes] type. Required. :type marketplace_gallery_images: - ~azure.mgmt.azurestackhci.models.MarketplaceGalleryImagesUpdateRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + ~azure.mgmt.azurestackhci.models.MarketplaceGalleryImagesUpdateRequest or IO[bytes] :return: An instance of AsyncLROPoller that returns either MarketplaceGalleryImages or the result of cls(response) :rtype: @@ -691,12 +618,13 @@ async def begin_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("MarketplaceGalleryImages", pipeline_response) + deserialized = self._deserialize("MarketplaceGalleryImages", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -709,17 +637,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.MarketplaceGalleryImages].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/marketplaceGalleryImages/{marketplaceGalleryImageName}" - } + return AsyncLROPoller[_models.MarketplaceGalleryImages]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.MarketplaceGalleryImages"]: @@ -729,7 +655,6 @@ def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_model :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either MarketplaceGalleryImages or the result of cls(response) :rtype: @@ -742,7 +667,7 @@ def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_model api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.MarketplaceGalleryImagesListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -753,16 +678,14 @@ def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_model def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -774,13 +697,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("MarketplaceGalleryImagesListResult", pipeline_response) @@ -790,11 +712,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -807,16 +729,11 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/marketplaceGalleryImages" - } - @distributed_trace def list_all(self, **kwargs: Any) -> AsyncIterable["_models.MarketplaceGalleryImages"]: """Lists all of the marketplace gallery images in the specified subscription. Use the nextLink property in the response to get the next page of marketplace gallery images. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either MarketplaceGalleryImages or the result of cls(response) :rtype: @@ -829,7 +746,7 @@ def list_all(self, **kwargs: Any) -> AsyncIterable["_models.MarketplaceGalleryIm api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.MarketplaceGalleryImagesListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -840,15 +757,13 @@ def list_all(self, **kwargs: Any) -> AsyncIterable["_models.MarketplaceGalleryIm def prepare_request(next_link=None): if not next_link: - request = build_list_all_request( + _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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -860,13 +775,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("MarketplaceGalleryImagesListResult", pipeline_response) @@ -876,11 +790,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -892,7 +806,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_all.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/marketplaceGalleryImages" - } diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_network_interfaces_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_network_interfaces_operations.py index bfced265b05f..2798ff5fdbeb 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_network_interfaces_operations.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_network_interfaces_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, 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.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._network_interfaces_operations import ( build_create_or_update_request, build_delete_request, @@ -40,6 +41,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -74,12 +79,11 @@ async def get( :type resource_group_name: str :param network_interface_name: Name of the network interface. Required. :type network_interface_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: NetworkInterfaces or the result of cls(response) :rtype: ~azure.mgmt.azurestackhci.models.NetworkInterfaces :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -93,21 +97,19 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.NetworkInterfaces] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, network_interface_name=network_interface_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -117,25 +119,21 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("NetworkInterfaces", pipeline_response) + deserialized = self._deserialize("NetworkInterfaces", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/networkInterfaces/{networkInterfaceName}" - } + return deserialized # type: ignore async def _create_or_update_initial( self, resource_group_name: str, network_interface_name: str, - network_interfaces: Union[_models.NetworkInterfaces, IO], + network_interfaces: Union[_models.NetworkInterfaces, IO[bytes]], **kwargs: Any - ) -> _models.NetworkInterfaces: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -148,7 +146,7 @@ async def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.NetworkInterfaces] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -158,7 +156,7 @@ async def _create_or_update_initial( else: _json = self._serialize.body(network_interfaces, "NetworkInterfaces") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, network_interface_name=network_interface_name, subscription_id=self._config.subscription_id, @@ -166,40 +164,35 @@ async def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("NetworkInterfaces", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("NetworkInterfaces", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/networkInterfaces/{networkInterfaceName}" - } - @overload async def begin_create_or_update( self, @@ -223,14 +216,6 @@ async def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either NetworkInterfaces or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.NetworkInterfaces] @@ -242,7 +227,7 @@ async def begin_create_or_update( self, resource_group_name: str, network_interface_name: str, - network_interfaces: IO, + network_interfaces: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -256,18 +241,10 @@ async def begin_create_or_update( :param network_interface_name: Name of the network interface. Required. :type network_interface_name: str :param network_interfaces: Required. - :type network_interfaces: IO + :type network_interfaces: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either NetworkInterfaces or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.NetworkInterfaces] @@ -279,7 +256,7 @@ async def begin_create_or_update( self, resource_group_name: str, network_interface_name: str, - network_interfaces: Union[_models.NetworkInterfaces, IO], + network_interfaces: Union[_models.NetworkInterfaces, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.NetworkInterfaces]: """The operation to create or update a network interface. Please note some properties can be set @@ -290,19 +267,8 @@ async def begin_create_or_update( :type resource_group_name: str :param network_interface_name: Name of the network interface. Required. :type network_interface_name: str - :param network_interfaces: Is either a NetworkInterfaces type or a IO type. Required. - :type network_interfaces: ~azure.mgmt.azurestackhci.models.NetworkInterfaces or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param network_interfaces: Is either a NetworkInterfaces type or a IO[bytes] type. Required. + :type network_interfaces: ~azure.mgmt.azurestackhci.models.NetworkInterfaces or IO[bytes] :return: An instance of AsyncLROPoller that returns either NetworkInterfaces or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.NetworkInterfaces] @@ -329,12 +295,13 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("NetworkInterfaces", pipeline_response) + deserialized = self._deserialize("NetworkInterfaces", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -347,22 +314,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.NetworkInterfaces].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/networkInterfaces/{networkInterfaceName}" - } + return AsyncLROPoller[_models.NetworkInterfaces]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, network_interface_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -374,28 +339,31 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, network_interface_name=network_interface_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) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -404,12 +372,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/networkInterfaces/{networkInterfaceName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -422,14 +390,6 @@ async def begin_delete( :type resource_group_name: str :param network_interface_name: Name of the network interface. Required. :type network_interface_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: @@ -443,7 +403,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, network_interface_name=network_interface_name, api_version=api_version, @@ -452,11 +412,12 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -468,26 +429,22 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/networkInterfaces/{networkInterfaceName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _update_initial( self, resource_group_name: str, network_interface_name: str, - network_interfaces: Union[_models.NetworkInterfacesUpdateRequest, IO], + network_interfaces: Union[_models.NetworkInterfacesUpdateRequest, IO[bytes]], **kwargs: Any - ) -> Optional[_models.NetworkInterfaces]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -500,7 +457,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.NetworkInterfaces]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -510,7 +467,7 @@ async def _update_initial( else: _json = self._serialize.body(network_interfaces, "NetworkInterfacesUpdateRequest") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, network_interface_name=network_interface_name, subscription_id=self._config.subscription_id, @@ -518,41 +475,38 @@ async def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("NetworkInterfaces", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/networkInterfaces/{networkInterfaceName}" - } + return deserialized # type: ignore @overload async def begin_update( @@ -576,14 +530,6 @@ async def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either NetworkInterfaces or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.NetworkInterfaces] @@ -595,7 +541,7 @@ async def begin_update( self, resource_group_name: str, network_interface_name: str, - network_interfaces: IO, + network_interfaces: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -608,18 +554,10 @@ async def begin_update( :param network_interface_name: Name of the network interface. Required. :type network_interface_name: str :param network_interfaces: Required. - :type network_interfaces: IO + :type network_interfaces: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either NetworkInterfaces or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.NetworkInterfaces] @@ -631,7 +569,7 @@ async def begin_update( self, resource_group_name: str, network_interface_name: str, - network_interfaces: Union[_models.NetworkInterfacesUpdateRequest, IO], + network_interfaces: Union[_models.NetworkInterfacesUpdateRequest, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.NetworkInterfaces]: """The operation to update a network interface. @@ -641,20 +579,10 @@ async def begin_update( :type resource_group_name: str :param network_interface_name: Name of the network interface. Required. :type network_interface_name: str - :param network_interfaces: Is either a NetworkInterfacesUpdateRequest type or a IO type. + :param network_interfaces: Is either a NetworkInterfacesUpdateRequest type or a IO[bytes] type. Required. - :type network_interfaces: ~azure.mgmt.azurestackhci.models.NetworkInterfacesUpdateRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :type network_interfaces: ~azure.mgmt.azurestackhci.models.NetworkInterfacesUpdateRequest or + IO[bytes] :return: An instance of AsyncLROPoller that returns either NetworkInterfaces or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.NetworkInterfaces] @@ -681,12 +609,13 @@ async def begin_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("NetworkInterfaces", pipeline_response) + deserialized = self._deserialize("NetworkInterfaces", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -699,17 +628,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.NetworkInterfaces].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/networkInterfaces/{networkInterfaceName}" - } + return AsyncLROPoller[_models.NetworkInterfaces]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.NetworkInterfaces"]: @@ -719,7 +646,6 @@ def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_model :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either NetworkInterfaces or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.NetworkInterfaces] @@ -731,7 +657,7 @@ def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_model api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.NetworkInterfacesListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -742,16 +668,14 @@ def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_model def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -763,13 +687,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("NetworkInterfacesListResult", pipeline_response) @@ -779,11 +702,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -796,16 +719,11 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/networkInterfaces" - } - @distributed_trace def list_all(self, **kwargs: Any) -> AsyncIterable["_models.NetworkInterfaces"]: """Lists all of the network interfaces in the specified subscription. Use the nextLink property in the response to get the next page of network interfaces. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either NetworkInterfaces or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.NetworkInterfaces] @@ -817,7 +735,7 @@ def list_all(self, **kwargs: Any) -> AsyncIterable["_models.NetworkInterfaces"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.NetworkInterfacesListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -828,15 +746,13 @@ def list_all(self, **kwargs: Any) -> AsyncIterable["_models.NetworkInterfaces"]: def prepare_request(next_link=None): if not next_link: - request = build_list_all_request( + _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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -848,13 +764,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("NetworkInterfacesListResult", pipeline_response) @@ -864,11 +779,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -880,5 +795,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_all.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/networkInterfaces"} diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_offers_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_offers_operations.py new file mode 100644 index 000000000000..3c1d6a1da3ed --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_offers_operations.py @@ -0,0 +1,319 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async 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 ...operations._offers_operations import ( + build_get_request, + build_list_by_cluster_request, + build_list_by_publisher_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class OffersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.azurestackhci.aio.AzureStackHCIClient`'s + :attr:`offers` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_publisher( + self, + resource_group_name: str, + cluster_name: str, + publisher_name: str, + expand: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.Offer"]: + """List Offers available for a publisher within the HCI Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param publisher_name: The name of the publisher available within HCI cluster. Required. + :type publisher_name: str + :param expand: Specify $expand=content,contentVersion to populate additional fields related to + the marketplace offer. Default value is None. + :type expand: str + :return: An iterator like instance of either Offer or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.Offer] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.OfferList] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_publisher_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + publisher_name=publisher_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("OfferList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_cluster( + self, resource_group_name: str, cluster_name: str, expand: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.Offer"]: + """List Offers available across publishers for the HCI Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param expand: Specify $expand=content,contentVersion to populate additional fields related to + the marketplace offer. Default value is None. + :type expand: str + :return: An iterator like instance of either Offer or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.Offer] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.OfferList] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_cluster_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("OfferList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + cluster_name: str, + publisher_name: str, + offer_name: str, + expand: Optional[str] = None, + **kwargs: Any + ) -> _models.Offer: + """Get Offer resource details within a publisher of HCI Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param publisher_name: The name of the publisher available within HCI cluster. Required. + :type publisher_name: str + :param offer_name: The name of the offer available within HCI cluster. Required. + :type offer_name: str + :param expand: Specify $expand=content,contentVersion to populate additional fields related to + the marketplace offer. Default value is None. + :type expand: str + :return: Offer or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.Offer + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.Offer] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + publisher_name=publisher_name, + offer_name=offer_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Offer", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_operations.py index 82cc3738edc8..2ea57019c0d3 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_operations.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,10 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -import urllib.parse +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar -from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( ClientAuthenticationError, HttpResponseError, @@ -19,16 +18,18 @@ 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.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._operations import build_list_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -52,22 +53,15 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: - """List all the supported operations. + @distributed_trace_async + async def list(self, **kwargs: Any) -> _models.OperationListResult: + """List all available Microsoft.AzureStackHCI provider operations. - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either Operation or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.Operation] + :return: OperationListResult or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.OperationListResult :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -75,59 +69,34 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: } 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) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("OperationListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.AzureStackHCI/operations"} + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) + + _request = build_list_request( + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("OperationListResult", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_publishers_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_publishers_operations.py new file mode 100644 index 000000000000..01acb51d017f --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_publishers_operations.py @@ -0,0 +1,202 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async 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 ...operations._publishers_operations import build_get_request, build_list_by_cluster_request + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class PublishersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.azurestackhci.aio.AzureStackHCIClient`'s + :attr:`publishers` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_cluster( + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Publisher"]: + """List Publishers available for the HCI Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :return: An iterator like instance of either Publisher or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.Publisher] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PublisherList] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_cluster_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("PublisherList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, resource_group_name: str, cluster_name: str, publisher_name: str, **kwargs: Any + ) -> _models.Publisher: + """Get Publisher resource details of HCI Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param publisher_name: The name of the publisher available within HCI cluster. Required. + :type publisher_name: str + :return: Publisher or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.Publisher + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.Publisher] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + publisher_name=publisher_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Publisher", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_security_settings_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_security_settings_operations.py new file mode 100644 index 000000000000..357ed26012ab --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_security_settings_operations.py @@ -0,0 +1,542 @@ +# pylint: disable=too-many-lines,too-many-statements +# 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 io import IOBase +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from 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 ...operations._security_settings_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_clusters_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class SecuritySettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.azurestackhci.aio.AzureStackHCIClient`'s + :attr:`security_settings` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_clusters( + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SecuritySetting"]: + """List SecuritySetting resources by Clusters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :return: An iterator like instance of either SecuritySetting or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.SecuritySetting] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SecuritySettingListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_clusters_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SecuritySettingListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, resource_group_name: str, cluster_name: str, security_settings_name: str = "default", **kwargs: Any + ) -> _models.SecuritySetting: + """Get a SecuritySetting. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param security_settings_name: Name of security setting. Default value is "default". + :type security_settings_name: str + :return: SecuritySetting or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.SecuritySetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SecuritySetting] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + security_settings_name=security_settings_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SecuritySetting", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + cluster_name: str, + resource: Union[_models.SecuritySetting, IO[bytes]], + security_settings_name: str = "default", + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IOBase, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "SecuritySetting") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + security_settings_name=security_settings_name, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + cluster_name: str, + resource: _models.SecuritySetting, + security_settings_name: str = "default", + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SecuritySetting]: + """Create a security setting. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param resource: Resource create parameters. Required. + :type resource: ~azure.mgmt.azurestackhci.models.SecuritySetting + :param security_settings_name: Name of security setting. Default value is "default". + :type security_settings_name: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either SecuritySetting or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.SecuritySetting] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + cluster_name: str, + resource: IO[bytes], + security_settings_name: str = "default", + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SecuritySetting]: + """Create a security setting. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param resource: Resource create parameters. Required. + :type resource: IO[bytes] + :param security_settings_name: Name of security setting. Default value is "default". + :type security_settings_name: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either SecuritySetting or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.SecuritySetting] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + cluster_name: str, + resource: Union[_models.SecuritySetting, IO[bytes]], + security_settings_name: str = "default", + **kwargs: Any + ) -> AsyncLROPoller[_models.SecuritySetting]: + """Create a security setting. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param resource: Resource create parameters. Is either a SecuritySetting type or a IO[bytes] + type. Required. + :type resource: ~azure.mgmt.azurestackhci.models.SecuritySetting or IO[bytes] + :param security_settings_name: Name of security setting. Default value is "default". + :type security_settings_name: str + :return: An instance of AsyncLROPoller that returns either SecuritySetting or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.SecuritySetting] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SecuritySetting] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + resource=resource, + security_settings_name=security_settings_name, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("SecuritySetting", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.SecuritySetting].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.SecuritySetting]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _delete_initial( + self, resource_group_name: str, cluster_name: str, security_settings_name: str = "default", **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + security_settings_name=security_settings_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, cluster_name: str, security_settings_name: str = "default", **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete a SecuritySetting. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param security_settings_name: Name of security setting. Default value is "default". + :type security_settings_name: str + :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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + security_settings_name=security_settings_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_skus_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_skus_operations.py new file mode 100644 index 000000000000..1128099c6cdb --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_skus_operations.py @@ -0,0 +1,235 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, Type, TypeVar +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async 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 ...operations._skus_operations import build_get_request, build_list_by_offer_request + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class SkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.azurestackhci.aio.AzureStackHCIClient`'s + :attr:`skus` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_offer( + self, + resource_group_name: str, + cluster_name: str, + publisher_name: str, + offer_name: str, + expand: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.Sku"]: + """List Skus available for a offer within the HCI Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param publisher_name: The name of the publisher available within HCI cluster. Required. + :type publisher_name: str + :param offer_name: The name of the offer available within HCI cluster. Required. + :type offer_name: str + :param expand: Specify $expand=content,contentVersion to populate additional fields related to + the marketplace offer. Default value is None. + :type expand: str + :return: An iterator like instance of either Sku or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.Sku] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SkuList] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_offer_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + publisher_name=publisher_name, + offer_name=offer_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SkuList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + cluster_name: str, + publisher_name: str, + offer_name: str, + sku_name: str, + expand: Optional[str] = None, + **kwargs: Any + ) -> _models.Sku: + """Get SKU resource details within a offer of HCI Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param publisher_name: The name of the publisher available within HCI cluster. Required. + :type publisher_name: str + :param offer_name: The name of the offer available within HCI cluster. Required. + :type offer_name: str + :param sku_name: The name of the SKU available within HCI cluster. Required. + :type sku_name: str + :param expand: Specify $expand=content,contentVersion to populate additional fields related to + the marketplace offer. Default value is None. + :type expand: str + :return: Sku or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.Sku + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.Sku] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + publisher_name=publisher_name, + offer_name=offer_name, + sku_name=sku_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Sku", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_storage_containers_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_storage_containers_operations.py index 3626bdba5382..8a65dee11a8e 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_storage_containers_operations.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_storage_containers_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, 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.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._storage_containers_operations import ( build_create_or_update_request, build_delete_request, @@ -40,6 +41,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -74,12 +79,11 @@ async def get( :type resource_group_name: str :param storage_container_name: Name of the storage container. Required. :type storage_container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageContainers or the result of cls(response) :rtype: ~azure.mgmt.azurestackhci.models.StorageContainers :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -93,21 +97,19 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.StorageContainers] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, storage_container_name=storage_container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -117,25 +119,21 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("StorageContainers", pipeline_response) + deserialized = self._deserialize("StorageContainers", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/storageContainers/{storageContainerName}" - } + return deserialized # type: ignore async def _create_or_update_initial( self, resource_group_name: str, storage_container_name: str, - storage_containers: Union[_models.StorageContainers, IO], + storage_containers: Union[_models.StorageContainers, IO[bytes]], **kwargs: Any - ) -> _models.StorageContainers: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -148,7 +146,7 @@ async def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.StorageContainers] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -158,7 +156,7 @@ async def _create_or_update_initial( else: _json = self._serialize.body(storage_containers, "StorageContainers") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, storage_container_name=storage_container_name, subscription_id=self._config.subscription_id, @@ -166,40 +164,35 @@ async def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("StorageContainers", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("StorageContainers", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/storageContainers/{storageContainerName}" - } - @overload async def begin_create_or_update( self, @@ -223,14 +216,6 @@ async def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either StorageContainers or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.StorageContainers] @@ -242,7 +227,7 @@ async def begin_create_or_update( self, resource_group_name: str, storage_container_name: str, - storage_containers: IO, + storage_containers: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -256,18 +241,10 @@ async def begin_create_or_update( :param storage_container_name: Name of the storage container. Required. :type storage_container_name: str :param storage_containers: Required. - :type storage_containers: IO + :type storage_containers: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either StorageContainers or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.StorageContainers] @@ -279,7 +256,7 @@ async def begin_create_or_update( self, resource_group_name: str, storage_container_name: str, - storage_containers: Union[_models.StorageContainers, IO], + storage_containers: Union[_models.StorageContainers, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.StorageContainers]: """The operation to create or update a storage container. Please note some properties can be set @@ -290,19 +267,8 @@ async def begin_create_or_update( :type resource_group_name: str :param storage_container_name: Name of the storage container. Required. :type storage_container_name: str - :param storage_containers: Is either a StorageContainers type or a IO type. Required. - :type storage_containers: ~azure.mgmt.azurestackhci.models.StorageContainers or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param storage_containers: Is either a StorageContainers type or a IO[bytes] type. Required. + :type storage_containers: ~azure.mgmt.azurestackhci.models.StorageContainers or IO[bytes] :return: An instance of AsyncLROPoller that returns either StorageContainers or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.StorageContainers] @@ -329,12 +295,13 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("StorageContainers", pipeline_response) + deserialized = self._deserialize("StorageContainers", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -347,22 +314,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.StorageContainers].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/storageContainers/{storageContainerName}" - } + return AsyncLROPoller[_models.StorageContainers]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, storage_container_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -374,28 +339,31 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, storage_container_name=storage_container_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) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -404,12 +372,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/storageContainers/{storageContainerName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -422,14 +390,6 @@ async def begin_delete( :type resource_group_name: str :param storage_container_name: Name of the storage container. Required. :type storage_container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -443,7 +403,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, storage_container_name=storage_container_name, api_version=api_version, @@ -452,11 +412,12 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -468,26 +429,22 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/storageContainers/{storageContainerName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _update_initial( self, resource_group_name: str, storage_container_name: str, - storage_containers: Union[_models.StorageContainersUpdateRequest, IO], + storage_containers: Union[_models.StorageContainersUpdateRequest, IO[bytes]], **kwargs: Any - ) -> Optional[_models.StorageContainers]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -500,7 +457,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.StorageContainers]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -510,7 +467,7 @@ async def _update_initial( else: _json = self._serialize.body(storage_containers, "StorageContainersUpdateRequest") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, storage_container_name=storage_container_name, subscription_id=self._config.subscription_id, @@ -518,41 +475,38 @@ async def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("StorageContainers", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/storageContainers/{storageContainerName}" - } + return deserialized # type: ignore @overload async def begin_update( @@ -576,14 +530,6 @@ async def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either StorageContainers or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.StorageContainers] @@ -595,7 +541,7 @@ async def begin_update( self, resource_group_name: str, storage_container_name: str, - storage_containers: IO, + storage_containers: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -608,18 +554,10 @@ async def begin_update( :param storage_container_name: Name of the storage container. Required. :type storage_container_name: str :param storage_containers: Required. - :type storage_containers: IO + :type storage_containers: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either StorageContainers or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.StorageContainers] @@ -631,7 +569,7 @@ async def begin_update( self, resource_group_name: str, storage_container_name: str, - storage_containers: Union[_models.StorageContainersUpdateRequest, IO], + storage_containers: Union[_models.StorageContainersUpdateRequest, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.StorageContainers]: """The operation to update a storage container. @@ -641,20 +579,10 @@ async def begin_update( :type resource_group_name: str :param storage_container_name: Name of the storage container. Required. :type storage_container_name: str - :param storage_containers: Is either a StorageContainersUpdateRequest type or a IO type. + :param storage_containers: Is either a StorageContainersUpdateRequest type or a IO[bytes] type. Required. - :type storage_containers: ~azure.mgmt.azurestackhci.models.StorageContainersUpdateRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :type storage_containers: ~azure.mgmt.azurestackhci.models.StorageContainersUpdateRequest or + IO[bytes] :return: An instance of AsyncLROPoller that returns either StorageContainers or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.StorageContainers] @@ -681,12 +609,13 @@ async def begin_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("StorageContainers", pipeline_response) + deserialized = self._deserialize("StorageContainers", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -699,17 +628,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.StorageContainers].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/storageContainers/{storageContainerName}" - } + return AsyncLROPoller[_models.StorageContainers]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.StorageContainers"]: @@ -719,7 +646,6 @@ def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_model :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageContainers or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.StorageContainers] @@ -731,7 +657,7 @@ def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_model api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.StorageContainersListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -742,16 +668,14 @@ def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_model def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -763,13 +687,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageContainersListResult", pipeline_response) @@ -779,11 +702,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -796,16 +719,11 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/storageContainers" - } - @distributed_trace def list_all(self, **kwargs: Any) -> AsyncIterable["_models.StorageContainers"]: """Lists all of the storage containers in the specified subscription. Use the nextLink property in the response to get the next page of storage containers. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageContainers or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.StorageContainers] @@ -817,7 +735,7 @@ def list_all(self, **kwargs: Any) -> AsyncIterable["_models.StorageContainers"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.StorageContainersListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -828,15 +746,13 @@ def list_all(self, **kwargs: Any) -> AsyncIterable["_models.StorageContainers"]: def prepare_request(next_link=None): if not next_link: - request = build_list_all_request( + _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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -848,13 +764,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("StorageContainersListResult", pipeline_response) @@ -864,11 +779,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -880,5 +795,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_all.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/storageContainers"} diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_update_runs_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_update_runs_operations.py new file mode 100644 index 000000000000..ba520d13901f --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_update_runs_operations.py @@ -0,0 +1,492 @@ +# pylint: disable=too-many-lines,too-many-statements +# 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 io import IOBase +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from 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 ...operations._update_runs_operations import ( + build_delete_request, + build_get_request, + build_list_request, + build_put_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class UpdateRunsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.azurestackhci.aio.AzureStackHCIClient`'s + :attr:`update_runs` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, cluster_name: str, update_name: str, **kwargs: Any + ) -> AsyncIterable["_models.UpdateRun"]: + """List all Update runs for a specified update. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param update_name: The name of the Update. Required. + :type update_name: str + :return: An iterator like instance of either UpdateRun or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.UpdateRun] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.UpdateRunList] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + update_name=update_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("UpdateRunList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + async def _delete_initial( + self, resource_group_name: str, cluster_name: str, update_name: str, update_run_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + update_name=update_name, + update_run_name=update_run_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, cluster_name: str, update_name: str, update_run_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete specified Update Run. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param update_name: The name of the Update. Required. + :type update_name: str + :param update_run_name: The name of the Update Run. Required. + :type update_run_name: str + :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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + update_name=update_name, + update_run_name=update_run_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @overload + async def put( + self, + resource_group_name: str, + cluster_name: str, + update_name: str, + update_run_name: str, + update_runs_properties: _models.UpdateRun, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UpdateRun: + """Put Update runs for a specified update. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param update_name: The name of the Update. Required. + :type update_name: str + :param update_run_name: The name of the Update Run. Required. + :type update_run_name: str + :param update_runs_properties: Properties of the updateRuns object. Required. + :type update_runs_properties: ~azure.mgmt.azurestackhci.models.UpdateRun + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: UpdateRun or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.UpdateRun + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def put( + self, + resource_group_name: str, + cluster_name: str, + update_name: str, + update_run_name: str, + update_runs_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UpdateRun: + """Put Update runs for a specified update. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param update_name: The name of the Update. Required. + :type update_name: str + :param update_run_name: The name of the Update Run. Required. + :type update_run_name: str + :param update_runs_properties: Properties of the updateRuns object. Required. + :type update_runs_properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: UpdateRun or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.UpdateRun + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def put( + self, + resource_group_name: str, + cluster_name: str, + update_name: str, + update_run_name: str, + update_runs_properties: Union[_models.UpdateRun, IO[bytes]], + **kwargs: Any + ) -> _models.UpdateRun: + """Put Update runs for a specified update. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param update_name: The name of the Update. Required. + :type update_name: str + :param update_run_name: The name of the Update Run. Required. + :type update_run_name: str + :param update_runs_properties: Properties of the updateRuns object. Is either a UpdateRun type + or a IO[bytes] type. Required. + :type update_runs_properties: ~azure.mgmt.azurestackhci.models.UpdateRun or IO[bytes] + :return: UpdateRun or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.UpdateRun + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.UpdateRun] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(update_runs_properties, (IOBase, bytes)): + _content = update_runs_properties + else: + _json = self._serialize.body(update_runs_properties, "UpdateRun") + + _request = build_put_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + update_name=update_name, + update_run_name=update_run_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("UpdateRun", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get( + self, resource_group_name: str, cluster_name: str, update_name: str, update_run_name: str, **kwargs: Any + ) -> _models.UpdateRun: + """Get the Update run for a specified update. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param update_name: The name of the Update. Required. + :type update_name: str + :param update_run_name: The name of the Update Run. Required. + :type update_run_name: str + :return: UpdateRun or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.UpdateRun + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.UpdateRun] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + update_name=update_name, + update_run_name=update_run_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("UpdateRun", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_update_summaries_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_update_summaries_operations.py new file mode 100644 index 000000000000..9d60e2f18315 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_update_summaries_operations.py @@ -0,0 +1,450 @@ +# pylint: disable=too-many-lines,too-many-statements +# 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 io import IOBase +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from 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 ...operations._update_summaries_operations import ( + build_delete_request, + build_get_request, + build_list_request, + build_put_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class UpdateSummariesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.azurestackhci.aio.AzureStackHCIClient`'s + :attr:`update_summaries` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> AsyncIterable["_models.UpdateSummaries"]: + """List all Update summaries under the HCI cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :return: An iterator like instance of either UpdateSummaries or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.UpdateSummaries] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.UpdateSummariesList] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("UpdateSummariesList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + async def _delete_initial(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Delete Update Summaries. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @overload + async def put( + self, + resource_group_name: str, + cluster_name: str, + update_location_properties: _models.UpdateSummaries, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UpdateSummaries: + """Put Update summaries under the HCI cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param update_location_properties: Properties of the UpdateSummaries resource. Required. + :type update_location_properties: ~azure.mgmt.azurestackhci.models.UpdateSummaries + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: UpdateSummaries or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.UpdateSummaries + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def put( + self, + resource_group_name: str, + cluster_name: str, + update_location_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UpdateSummaries: + """Put Update summaries under the HCI cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param update_location_properties: Properties of the UpdateSummaries resource. Required. + :type update_location_properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: UpdateSummaries or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.UpdateSummaries + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def put( + self, + resource_group_name: str, + cluster_name: str, + update_location_properties: Union[_models.UpdateSummaries, IO[bytes]], + **kwargs: Any + ) -> _models.UpdateSummaries: + """Put Update summaries under the HCI cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param update_location_properties: Properties of the UpdateSummaries resource. Is either a + UpdateSummaries type or a IO[bytes] type. Required. + :type update_location_properties: ~azure.mgmt.azurestackhci.models.UpdateSummaries or IO[bytes] + :return: UpdateSummaries or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.UpdateSummaries + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.UpdateSummaries] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(update_location_properties, (IOBase, bytes)): + _content = update_location_properties + else: + _json = self._serialize.body(update_location_properties, "UpdateSummaries") + + _request = build_put_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("UpdateSummaries", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> _models.UpdateSummaries: + """Get all Update summaries under the HCI cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :return: UpdateSummaries or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.UpdateSummaries + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.UpdateSummaries] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("UpdateSummaries", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_updates_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_updates_operations.py new file mode 100644 index 000000000000..c5274eb896d0 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_updates_operations.py @@ -0,0 +1,588 @@ +# pylint: disable=too-many-lines,too-many-statements +# 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 io import IOBase +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from 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 ...operations._updates_operations import ( + build_delete_request, + build_get_request, + build_list_request, + build_post_request, + build_put_request, +) + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class UpdatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.azurestackhci.aio.AzureStackHCIClient`'s + :attr:`updates` 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 _post_initial( + self, resource_group_name: str, cluster_name: str, update_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_post_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + update_name=update_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_post( + self, resource_group_name: str, cluster_name: str, update_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Apply Update. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param update_name: The name of the Update. Required. + :type update_name: str + :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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._post_initial( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + update_name=update_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> AsyncIterable["_models.Update"]: + """List all Updates. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :return: An iterator like instance of either Update or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.Update] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.UpdateList] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("UpdateList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + async def _delete_initial( + self, resource_group_name: str, cluster_name: str, update_name: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + update_name=update_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, cluster_name: str, update_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete specified Update. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param update_name: The name of the Update. Required. + :type update_name: str + :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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + update_name=update_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @overload + async def put( + self, + resource_group_name: str, + cluster_name: str, + update_name: str, + update_properties: _models.Update, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Update: + """Put specified Update. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param update_name: The name of the Update. Required. + :type update_name: str + :param update_properties: Properties of the Updates object. Required. + :type update_properties: ~azure.mgmt.azurestackhci.models.Update + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Update or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.Update + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def put( + self, + resource_group_name: str, + cluster_name: str, + update_name: str, + update_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Update: + """Put specified Update. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param update_name: The name of the Update. Required. + :type update_name: str + :param update_properties: Properties of the Updates object. Required. + :type update_properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: Update or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.Update + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def put( + self, + resource_group_name: str, + cluster_name: str, + update_name: str, + update_properties: Union[_models.Update, IO[bytes]], + **kwargs: Any + ) -> _models.Update: + """Put specified Update. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param update_name: The name of the Update. Required. + :type update_name: str + :param update_properties: Properties of the Updates object. Is either a Update type or a + IO[bytes] type. Required. + :type update_properties: ~azure.mgmt.azurestackhci.models.Update or IO[bytes] + :return: Update or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.Update + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Update] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(update_properties, (IOBase, bytes)): + _content = update_properties + else: + _json = self._serialize.body(update_properties, "Update") + + _request = build_put_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + update_name=update_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Update", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get(self, resource_group_name: str, cluster_name: str, update_name: str, **kwargs: Any) -> _models.Update: + """Get specified Update. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param update_name: The name of the Update. Required. + :type update_name: str + :return: Update or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.Update + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.Update] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + update_name=update_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Update", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_virtual_hard_disks_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_virtual_hard_disks_operations.py index ab7c6da3e30e..06b238bbe008 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_virtual_hard_disks_operations.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_virtual_hard_disks_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, 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.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._virtual_hard_disks_operations import ( build_create_or_update_request, build_delete_request, @@ -40,6 +41,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -74,12 +79,11 @@ async def get( :type resource_group_name: str :param virtual_hard_disk_name: Name of the virtual hard disk. Required. :type virtual_hard_disk_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: VirtualHardDisks or the result of cls(response) :rtype: ~azure.mgmt.azurestackhci.models.VirtualHardDisks :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -93,21 +97,19 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.VirtualHardDisks] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, virtual_hard_disk_name=virtual_hard_disk_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -117,25 +119,21 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("VirtualHardDisks", pipeline_response) + deserialized = self._deserialize("VirtualHardDisks", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualHardDisks/{virtualHardDiskName}" - } + return deserialized # type: ignore async def _create_or_update_initial( self, resource_group_name: str, virtual_hard_disk_name: str, - virtual_hard_disks: Union[_models.VirtualHardDisks, IO], + virtual_hard_disks: Union[_models.VirtualHardDisks, IO[bytes]], **kwargs: Any - ) -> _models.VirtualHardDisks: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -148,7 +146,7 @@ async def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualHardDisks] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -158,7 +156,7 @@ async def _create_or_update_initial( else: _json = self._serialize.body(virtual_hard_disks, "VirtualHardDisks") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, virtual_hard_disk_name=virtual_hard_disk_name, subscription_id=self._config.subscription_id, @@ -166,40 +164,35 @@ async def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("VirtualHardDisks", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("VirtualHardDisks", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualHardDisks/{virtualHardDiskName}" - } - @overload async def begin_create_or_update( self, @@ -223,14 +216,6 @@ async def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either VirtualHardDisks or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.VirtualHardDisks] @@ -242,7 +227,7 @@ async def begin_create_or_update( self, resource_group_name: str, virtual_hard_disk_name: str, - virtual_hard_disks: IO, + virtual_hard_disks: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -256,18 +241,10 @@ async def begin_create_or_update( :param virtual_hard_disk_name: Name of the virtual hard disk. Required. :type virtual_hard_disk_name: str :param virtual_hard_disks: Required. - :type virtual_hard_disks: IO + :type virtual_hard_disks: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either VirtualHardDisks or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.VirtualHardDisks] @@ -279,7 +256,7 @@ async def begin_create_or_update( self, resource_group_name: str, virtual_hard_disk_name: str, - virtual_hard_disks: Union[_models.VirtualHardDisks, IO], + virtual_hard_disks: Union[_models.VirtualHardDisks, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.VirtualHardDisks]: """The operation to create or update a virtual hard disk. Please note some properties can be set @@ -290,19 +267,8 @@ async def begin_create_or_update( :type resource_group_name: str :param virtual_hard_disk_name: Name of the virtual hard disk. Required. :type virtual_hard_disk_name: str - :param virtual_hard_disks: Is either a VirtualHardDisks type or a IO type. Required. - :type virtual_hard_disks: ~azure.mgmt.azurestackhci.models.VirtualHardDisks or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param virtual_hard_disks: Is either a VirtualHardDisks type or a IO[bytes] type. Required. + :type virtual_hard_disks: ~azure.mgmt.azurestackhci.models.VirtualHardDisks or IO[bytes] :return: An instance of AsyncLROPoller that returns either VirtualHardDisks or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.VirtualHardDisks] @@ -329,12 +295,13 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualHardDisks", pipeline_response) + deserialized = self._deserialize("VirtualHardDisks", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -347,22 +314,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.VirtualHardDisks].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualHardDisks/{virtualHardDiskName}" - } + return AsyncLROPoller[_models.VirtualHardDisks]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements + async def _delete_initial( self, resource_group_name: str, virtual_hard_disk_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -374,28 +339,31 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, virtual_hard_disk_name=virtual_hard_disk_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) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -404,12 +372,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualHardDisks/{virtualHardDiskName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -422,14 +390,6 @@ async def begin_delete( :type resource_group_name: str :param virtual_hard_disk_name: Name of the virtual hard disk. Required. :type virtual_hard_disk_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: @@ -443,7 +403,7 @@ async def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_group_name=resource_group_name, virtual_hard_disk_name=virtual_hard_disk_name, api_version=api_version, @@ -452,11 +412,12 @@ async def begin_delete( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -468,26 +429,22 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualHardDisks/{virtualHardDiskName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _update_initial( self, resource_group_name: str, virtual_hard_disk_name: str, - virtual_hard_disks: Union[_models.VirtualHardDisksUpdateRequest, IO], + virtual_hard_disks: Union[_models.VirtualHardDisksUpdateRequest, IO[bytes]], **kwargs: Any - ) -> Optional[_models.VirtualHardDisks]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -500,7 +457,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.VirtualHardDisks]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -510,7 +467,7 @@ async def _update_initial( else: _json = self._serialize.body(virtual_hard_disks, "VirtualHardDisksUpdateRequest") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, virtual_hard_disk_name=virtual_hard_disk_name, subscription_id=self._config.subscription_id, @@ -518,41 +475,38 @@ async def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("VirtualHardDisks", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualHardDisks/{virtualHardDiskName}" - } + return deserialized # type: ignore @overload async def begin_update( @@ -576,14 +530,6 @@ async def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either VirtualHardDisks or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.VirtualHardDisks] @@ -595,7 +541,7 @@ async def begin_update( self, resource_group_name: str, virtual_hard_disk_name: str, - virtual_hard_disks: IO, + virtual_hard_disks: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -608,18 +554,10 @@ async def begin_update( :param virtual_hard_disk_name: Name of the virtual hard disk. Required. :type virtual_hard_disk_name: str :param virtual_hard_disks: Required. - :type virtual_hard_disks: IO + :type virtual_hard_disks: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either VirtualHardDisks or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.VirtualHardDisks] @@ -631,7 +569,7 @@ async def begin_update( self, resource_group_name: str, virtual_hard_disk_name: str, - virtual_hard_disks: Union[_models.VirtualHardDisksUpdateRequest, IO], + virtual_hard_disks: Union[_models.VirtualHardDisksUpdateRequest, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.VirtualHardDisks]: """The operation to update a virtual hard disk. @@ -641,20 +579,10 @@ async def begin_update( :type resource_group_name: str :param virtual_hard_disk_name: Name of the virtual hard disk. Required. :type virtual_hard_disk_name: str - :param virtual_hard_disks: Is either a VirtualHardDisksUpdateRequest type or a IO type. + :param virtual_hard_disks: Is either a VirtualHardDisksUpdateRequest type or a IO[bytes] type. Required. - :type virtual_hard_disks: ~azure.mgmt.azurestackhci.models.VirtualHardDisksUpdateRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :type virtual_hard_disks: ~azure.mgmt.azurestackhci.models.VirtualHardDisksUpdateRequest or + IO[bytes] :return: An instance of AsyncLROPoller that returns either VirtualHardDisks or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.azurestackhci.models.VirtualHardDisks] @@ -681,12 +609,13 @@ async def begin_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualHardDisks", pipeline_response) + deserialized = self._deserialize("VirtualHardDisks", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -699,17 +628,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.VirtualHardDisks].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualHardDisks/{virtualHardDiskName}" - } + return AsyncLROPoller[_models.VirtualHardDisks]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.VirtualHardDisks"]: @@ -719,7 +646,6 @@ def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_model :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either VirtualHardDisks or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.VirtualHardDisks] @@ -731,7 +657,7 @@ def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_model api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.VirtualHardDisksListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -742,16 +668,14 @@ def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_model def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -763,13 +687,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("VirtualHardDisksListResult", pipeline_response) @@ -779,11 +702,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -796,16 +719,11 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualHardDisks" - } - @distributed_trace def list_all(self, **kwargs: Any) -> AsyncIterable["_models.VirtualHardDisks"]: """Lists all of the virtual hard disks in the specified subscription. Use the nextLink property in the response to get the next page of virtual hard disks. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either VirtualHardDisks or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.azurestackhci.models.VirtualHardDisks] @@ -817,7 +735,7 @@ def list_all(self, **kwargs: Any) -> AsyncIterable["_models.VirtualHardDisks"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.VirtualHardDisksListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -828,15 +746,13 @@ def list_all(self, **kwargs: Any) -> AsyncIterable["_models.VirtualHardDisks"]: def prepare_request(next_link=None): if not next_link: - request = build_list_all_request( + _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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -848,13 +764,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("VirtualHardDisksListResult", pipeline_response) @@ -864,11 +779,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -880,5 +795,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_all.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/virtualHardDisks"} diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_virtual_machine_instances_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_virtual_machine_instances_operations.py index 6f06b12fee9b..c3b1dd0b706f 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_virtual_machine_instances_operations.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/aio/operations/_virtual_machine_instances_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -17,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, 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.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -30,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._virtual_machine_instances_operations import ( build_create_or_update_request, build_delete_request, @@ -42,6 +43,10 @@ build_update_request, ) +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -72,12 +77,11 @@ async def get(self, resource_uri: str, **kwargs: Any) -> _models.VirtualMachineI :param resource_uri: The fully qualified Azure Resource manager identifier of the Hybrid Compute machine resource to be extended. Required. :type resource_uri: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: VirtualMachineInstance or the result of cls(response) :rtype: ~azure.mgmt.azurestackhci.models.VirtualMachineInstance :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -91,19 +95,17 @@ async def get(self, resource_uri: str, **kwargs: Any) -> _models.VirtualMachineI api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.VirtualMachineInstance] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_uri=resource_uri, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -113,19 +115,20 @@ async def get(self, resource_uri: str, **kwargs: Any) -> _models.VirtualMachineI error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("VirtualMachineInstance", pipeline_response) + deserialized = self._deserialize("VirtualMachineInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = {"url": "/{resourceUri}/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default"} + return deserialized # type: ignore async def _create_or_update_initial( - self, resource_uri: str, virtual_machine_instance: Union[_models.VirtualMachineInstance, IO], **kwargs: Any - ) -> _models.VirtualMachineInstance: - error_map = { + self, + resource_uri: str, + virtual_machine_instance: Union[_models.VirtualMachineInstance, IO[bytes]], + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -138,7 +141,7 @@ async def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineInstance] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -148,46 +151,41 @@ async def _create_or_update_initial( else: _json = self._serialize.body(virtual_machine_instance, "VirtualMachineInstance") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_uri=resource_uri, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("VirtualMachineInstance", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("VirtualMachineInstance", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/{resourceUri}/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default" - } - @overload async def begin_create_or_update( self, @@ -208,14 +206,6 @@ async def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either VirtualMachineInstance or the result of cls(response) :rtype: @@ -225,7 +215,12 @@ async def begin_create_or_update( @overload async def begin_create_or_update( - self, resource_uri: str, virtual_machine_instance: IO, *, content_type: str = "application/json", **kwargs: Any + self, + resource_uri: str, + virtual_machine_instance: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any ) -> AsyncLROPoller[_models.VirtualMachineInstance]: """The operation to create or update a virtual machine instance. Please note some properties can be set only during virtual machine instance creation. @@ -234,18 +229,10 @@ async def begin_create_or_update( Compute machine resource to be extended. Required. :type resource_uri: str :param virtual_machine_instance: Required. - :type virtual_machine_instance: IO + :type virtual_machine_instance: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either VirtualMachineInstance or the result of cls(response) :rtype: @@ -255,7 +242,10 @@ async def begin_create_or_update( @distributed_trace_async async def begin_create_or_update( - self, resource_uri: str, virtual_machine_instance: Union[_models.VirtualMachineInstance, IO], **kwargs: Any + self, + resource_uri: str, + virtual_machine_instance: Union[_models.VirtualMachineInstance, IO[bytes]], + **kwargs: Any ) -> AsyncLROPoller[_models.VirtualMachineInstance]: """The operation to create or update a virtual machine instance. Please note some properties can be set only during virtual machine instance creation. @@ -263,20 +253,10 @@ async def begin_create_or_update( :param resource_uri: The fully qualified Azure Resource manager identifier of the Hybrid Compute machine resource to be extended. Required. :type resource_uri: str - :param virtual_machine_instance: Is either a VirtualMachineInstance type or a IO type. + :param virtual_machine_instance: Is either a VirtualMachineInstance type or a IO[bytes] type. Required. - :type virtual_machine_instance: ~azure.mgmt.azurestackhci.models.VirtualMachineInstance or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :type virtual_machine_instance: ~azure.mgmt.azurestackhci.models.VirtualMachineInstance or + IO[bytes] :return: An instance of AsyncLROPoller that returns either VirtualMachineInstance or the result of cls(response) :rtype: @@ -303,12 +283,13 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineInstance", pipeline_response) + deserialized = self._deserialize("VirtualMachineInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -321,22 +302,18 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.VirtualMachineInstance].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/{resourceUri}/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default" - } + return AsyncLROPoller[_models.VirtualMachineInstance]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_uri: str, **kwargs: Any - ) -> None: - error_map = { + async def _delete_initial(self, resource_uri: str, **kwargs: Any) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -348,26 +325,29 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_uri=resource_uri, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202, 204]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -376,12 +356,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/{resourceUri}/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete(self, resource_uri: str, **kwargs: Any) -> AsyncLROPoller[None]: @@ -390,14 +370,6 @@ async def begin_delete(self, resource_uri: str, **kwargs: Any) -> AsyncLROPoller :param resource_uri: The fully qualified Azure Resource manager identifier of the Hybrid Compute machine resource to be extended. Required. :type resource_uri: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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: @@ -411,7 +383,7 @@ async def begin_delete(self, resource_uri: str, **kwargs: Any) -> AsyncLROPoller lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._delete_initial( # type: ignore + raw_result = await self._delete_initial( resource_uri=resource_uri, api_version=api_version, cls=lambda x, y, z: x, @@ -419,11 +391,12 @@ async def begin_delete(self, resource_uri: str, **kwargs: Any) -> AsyncLROPoller params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -435,23 +408,21 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = {"url": "/{resourceUri}/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default"} + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _update_initial( self, resource_uri: str, - virtual_machine_instance: Union[_models.VirtualMachineInstanceUpdateRequest, IO], + virtual_machine_instance: Union[_models.VirtualMachineInstanceUpdateRequest, IO[bytes]], **kwargs: Any - ) -> Optional[_models.VirtualMachineInstance]: - error_map = { + ) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -464,7 +435,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.VirtualMachineInstance]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -474,47 +445,44 @@ async def _update_initial( else: _json = self._serialize.body(virtual_machine_instance, "VirtualMachineInstanceUpdateRequest") - request = build_update_request( + _request = build_update_request( resource_uri=resource_uri, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("VirtualMachineInstance", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _update_initial.metadata = { - "url": "/{resourceUri}/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default" - } + return deserialized # type: ignore @overload async def begin_update( @@ -536,14 +504,6 @@ async def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either VirtualMachineInstance or the result of cls(response) :rtype: @@ -553,7 +513,12 @@ async def begin_update( @overload async def begin_update( - self, resource_uri: str, virtual_machine_instance: IO, *, content_type: str = "application/json", **kwargs: Any + self, + resource_uri: str, + virtual_machine_instance: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any ) -> AsyncLROPoller[_models.VirtualMachineInstance]: """The operation to update a virtual machine instance. @@ -561,18 +526,10 @@ async def begin_update( Compute machine resource to be extended. Required. :type resource_uri: str :param virtual_machine_instance: Required. - :type virtual_machine_instance: IO + :type virtual_machine_instance: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of AsyncLROPoller that returns either VirtualMachineInstance or the result of cls(response) :rtype: @@ -584,7 +541,7 @@ async def begin_update( async def begin_update( self, resource_uri: str, - virtual_machine_instance: Union[_models.VirtualMachineInstanceUpdateRequest, IO], + virtual_machine_instance: Union[_models.VirtualMachineInstanceUpdateRequest, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.VirtualMachineInstance]: """The operation to update a virtual machine instance. @@ -592,21 +549,10 @@ async def begin_update( :param resource_uri: The fully qualified Azure Resource manager identifier of the Hybrid Compute machine resource to be extended. Required. :type resource_uri: str - :param virtual_machine_instance: Is either a VirtualMachineInstanceUpdateRequest type or a IO - type. Required. + :param virtual_machine_instance: Is either a VirtualMachineInstanceUpdateRequest type or a + IO[bytes] type. Required. :type virtual_machine_instance: - ~azure.mgmt.azurestackhci.models.VirtualMachineInstanceUpdateRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + ~azure.mgmt.azurestackhci.models.VirtualMachineInstanceUpdateRequest or IO[bytes] :return: An instance of AsyncLROPoller that returns either VirtualMachineInstance or the result of cls(response) :rtype: @@ -633,12 +579,13 @@ async def begin_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineInstance", pipeline_response) + deserialized = self._deserialize("VirtualMachineInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -651,18 +598,18 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.VirtualMachineInstance].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = {"url": "/{resourceUri}/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default"} + return AsyncLROPoller[_models.VirtualMachineInstance]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _start_initial(self, resource_uri: str, **kwargs: Any) -> Optional[_models.VirtualMachineInstance]: - error_map = { + async def _start_initial(self, resource_uri: str, **kwargs: Any) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -674,46 +621,43 @@ async def _start_initial(self, resource_uri: str, **kwargs: Any) -> Optional[_mo _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[Optional[_models.VirtualMachineInstance]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_start_request( + _request = build_start_request( resource_uri=resource_uri, 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("VirtualMachineInstance", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _start_initial.metadata = { - "url": "/{resourceUri}/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default/start" - } + return deserialized # type: ignore @distributed_trace_async async def begin_start(self, resource_uri: str, **kwargs: Any) -> AsyncLROPoller[_models.VirtualMachineInstance]: @@ -722,14 +666,6 @@ async def begin_start(self, resource_uri: str, **kwargs: Any) -> AsyncLROPoller[ :param resource_uri: The fully qualified Azure Resource manager identifier of the Hybrid Compute machine resource to be extended. Required. :type resource_uri: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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 VirtualMachineInstance or the result of cls(response) :rtype: @@ -753,12 +689,13 @@ async def begin_start(self, resource_uri: str, **kwargs: Any) -> AsyncLROPoller[ params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineInstance", pipeline_response) + deserialized = self._deserialize("VirtualMachineInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -770,20 +707,18 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.VirtualMachineInstance].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_start.metadata = { - "url": "/{resourceUri}/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default/start" - } + return AsyncLROPoller[_models.VirtualMachineInstance]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _stop_initial(self, resource_uri: str, **kwargs: Any) -> Optional[_models.VirtualMachineInstance]: - error_map = { + async def _stop_initial(self, resource_uri: str, **kwargs: Any) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -795,46 +730,43 @@ async def _stop_initial(self, resource_uri: str, **kwargs: Any) -> Optional[_mod _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[Optional[_models.VirtualMachineInstance]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_stop_request( + _request = build_stop_request( resource_uri=resource_uri, api_version=api_version, - template_url=self._stop_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("VirtualMachineInstance", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _stop_initial.metadata = { - "url": "/{resourceUri}/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default/stop" - } + return deserialized # type: ignore @distributed_trace_async async def begin_stop(self, resource_uri: str, **kwargs: Any) -> AsyncLROPoller[_models.VirtualMachineInstance]: @@ -843,14 +775,6 @@ async def begin_stop(self, resource_uri: str, **kwargs: Any) -> AsyncLROPoller[_ :param resource_uri: The fully qualified Azure Resource manager identifier of the Hybrid Compute machine resource to be extended. Required. :type resource_uri: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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 VirtualMachineInstance or the result of cls(response) :rtype: @@ -874,12 +798,13 @@ async def begin_stop(self, resource_uri: str, **kwargs: Any) -> AsyncLROPoller[_ params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineInstance", pipeline_response) + deserialized = self._deserialize("VirtualMachineInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -891,20 +816,18 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.VirtualMachineInstance].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_stop.metadata = { - "url": "/{resourceUri}/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default/stop" - } + return AsyncLROPoller[_models.VirtualMachineInstance]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - async def _restart_initial(self, resource_uri: str, **kwargs: Any) -> Optional[_models.VirtualMachineInstance]: - error_map = { + async def _restart_initial(self, resource_uri: str, **kwargs: Any) -> AsyncIterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -916,46 +839,43 @@ async def _restart_initial(self, resource_uri: str, **kwargs: Any) -> Optional[_ _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[Optional[_models.VirtualMachineInstance]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - request = build_restart_request( + _request = build_restart_request( resource_uri=resource_uri, 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("VirtualMachineInstance", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _restart_initial.metadata = { - "url": "/{resourceUri}/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default/restart" - } + return deserialized # type: ignore @distributed_trace_async async def begin_restart(self, resource_uri: str, **kwargs: Any) -> AsyncLROPoller[_models.VirtualMachineInstance]: @@ -964,14 +884,6 @@ async def begin_restart(self, resource_uri: str, **kwargs: Any) -> AsyncLROPolle :param resource_uri: The fully qualified Azure Resource manager identifier of the Hybrid Compute machine resource to be extended. Required. :type resource_uri: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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 VirtualMachineInstance or the result of cls(response) :rtype: @@ -995,12 +907,13 @@ async def begin_restart(self, resource_uri: str, **kwargs: Any) -> AsyncLROPolle params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineInstance", pipeline_response) + deserialized = self._deserialize("VirtualMachineInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1012,17 +925,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.VirtualMachineInstance].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_restart.metadata = { - "url": "/{resourceUri}/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default/restart" - } + return AsyncLROPoller[_models.VirtualMachineInstance]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def list(self, resource_uri: str, **kwargs: Any) -> AsyncIterable["_models.VirtualMachineInstance"]: @@ -1031,7 +942,6 @@ def list(self, resource_uri: str, **kwargs: Any) -> AsyncIterable["_models.Virtu :param resource_uri: The fully qualified Azure Resource manager identifier of the Hybrid Compute machine resource to be extended. Required. :type resource_uri: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either VirtualMachineInstance or the result of cls(response) :rtype: @@ -1044,7 +954,7 @@ def list(self, resource_uri: str, **kwargs: Any) -> AsyncIterable["_models.Virtu api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.VirtualMachineInstanceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1055,15 +965,13 @@ def list(self, resource_uri: str, **kwargs: Any) -> AsyncIterable["_models.Virtu def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_uri=resource_uri, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1075,13 +983,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request async def extract_data(pipeline_response): deserialized = self._deserialize("VirtualMachineInstanceListResult", pipeline_response) @@ -1091,11 +998,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1107,5 +1014,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/{resourceUri}/providers/Microsoft.AzureStackHCI/virtualMachineInstances"} diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/models/__init__.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/models/__init__.py index 8d80f49afacc..3805e43e502b 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/models/__init__.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/models/__init__.py @@ -6,10 +6,42 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from ._models_py3 import AdapterPropertyOverrides +from ._models_py3 import ArcConnectivityProperties +from ._models_py3 import ArcIdentityResponse +from ._models_py3 import ArcSetting +from ._models_py3 import ArcSettingList +from ._models_py3 import ArcSettingsPatch +from ._models_py3 import Cluster +from ._models_py3 import ClusterDesiredProperties +from ._models_py3 import ClusterIdentityResponse +from ._models_py3 import ClusterList +from ._models_py3 import ClusterNode +from ._models_py3 import ClusterPatch +from ._models_py3 import ClusterReportedProperties +from ._models_py3 import DefaultExtensionDetails +from ._models_py3 import DeploymentCluster +from ._models_py3 import DeploymentConfiguration +from ._models_py3 import DeploymentData +from ._models_py3 import DeploymentSecuritySettings +from ._models_py3 import DeploymentSetting +from ._models_py3 import DeploymentSettingListResult +from ._models_py3 import DeploymentStatus +from ._models_py3 import DeploymentStep +from ._models_py3 import DeviceConfiguration +from ._models_py3 import EdgeDevice +from ._models_py3 import EdgeDeviceListResult from ._models_py3 import ErrorAdditionalInfo from ._models_py3 import ErrorDetail from ._models_py3 import ErrorResponse from ._models_py3 import ExtendedLocation +from ._models_py3 import Extension +from ._models_py3 import ExtensionInstanceView +from ._models_py3 import ExtensionInstanceViewStatus +from ._models_py3 import ExtensionList +from ._models_py3 import ExtensionPatch +from ._models_py3 import ExtensionPatchParameters +from ._models_py3 import ExtensionUpgradeParameters from ._models_py3 import GalleryDiskImage from ._models_py3 import GalleryImageIdentifier from ._models_py3 import GalleryImageStatus @@ -26,6 +58,7 @@ from ._models_py3 import GuestAgentList from ._models_py3 import GuestCredential from ._models_py3 import HardwareProfileUpdate +from ._models_py3 import HostNetwork from ._models_py3 import HttpProxyConfiguration from ._models_py3 import HybridIdentityMetadata from ._models_py3 import HybridIdentityMetadataList @@ -35,8 +68,12 @@ from ._models_py3 import IPPool from ._models_py3 import IPPoolInfo from ._models_py3 import Identity +from ._models_py3 import InfrastructureNetwork from ._models_py3 import InstanceViewStatus +from ._models_py3 import Intents from ._models_py3 import InterfaceDNSSettings +from ._models_py3 import IpPools +from ._models_py3 import IsolatedVmAttestationConfiguration from ._models_py3 import LogicalNetworkPropertiesDhcpOptions from ._models_py3 import LogicalNetworkStatus from ._models_py3 import LogicalNetworkStatusProvisioningStatus @@ -56,29 +93,72 @@ from ._models_py3 import NetworkInterfacesUpdateRequest from ._models_py3 import NetworkProfileUpdate from ._models_py3 import NetworkProfileUpdateNetworkInterfacesItem +from ._models_py3 import NicDetail +from ._models_py3 import Observability +from ._models_py3 import Offer +from ._models_py3 import OfferList from ._models_py3 import Operation from ._models_py3 import OperationDisplay from ._models_py3 import OperationListResult +from ._models_py3 import OptionalServices from ._models_py3 import OsProfileUpdate from ._models_py3 import OsProfileUpdateLinuxConfiguration from ._models_py3 import OsProfileUpdateWindowsConfiguration +from ._models_py3 import PackageVersionInfo +from ._models_py3 import PasswordCredential +from ._models_py3 import PerNodeExtensionState +from ._models_py3 import PerNodeState +from ._models_py3 import PhysicalNodes +from ._models_py3 import PrecheckResult +from ._models_py3 import PrecheckResultTags from ._models_py3 import ProxyResource +from ._models_py3 import Publisher +from ._models_py3 import PublisherList +from ._models_py3 import QosPolicyOverrides +from ._models_py3 import RawCertificateData +from ._models_py3 import ReportedProperties from ._models_py3 import Resource from ._models_py3 import Route from ._models_py3 import RouteTable +from ._models_py3 import ScaleUnits +from ._models_py3 import SecurityComplianceStatus +from ._models_py3 import SecuritySetting +from ._models_py3 import SecuritySettingListResult +from ._models_py3 import ServiceConfiguration +from ._models_py3 import Sku +from ._models_py3 import SkuList +from ._models_py3 import SkuMappings +from ._models_py3 import SoftwareAssuranceChangeRequest +from ._models_py3 import SoftwareAssuranceChangeRequestProperties +from ._models_py3 import SoftwareAssuranceProperties from ._models_py3 import SshConfiguration from ._models_py3 import SshPublicKey +from ._models_py3 import Step +from ._models_py3 import Storage from ._models_py3 import StorageContainerStatus from ._models_py3 import StorageContainerStatusProvisioningStatus from ._models_py3 import StorageContainers from ._models_py3 import StorageContainersListResult from ._models_py3 import StorageContainersUpdateRequest +from ._models_py3 import StorageNetworks from ._models_py3 import StorageProfileUpdate from ._models_py3 import StorageProfileUpdateDataDisksItem from ._models_py3 import Subnet from ._models_py3 import SubnetPropertiesFormatIpConfigurationReferencesItem from ._models_py3 import SystemData from ._models_py3 import TrackedResource +from ._models_py3 import Update +from ._models_py3 import UpdateList +from ._models_py3 import UpdatePrerequisite +from ._models_py3 import UpdateRun +from ._models_py3 import UpdateRunList +from ._models_py3 import UpdateSummaries +from ._models_py3 import UpdateSummariesList +from ._models_py3 import UploadCertificateRequest +from ._models_py3 import UserAssignedIdentity +from ._models_py3 import ValidateRequest +from ._models_py3 import ValidateResponse +from ._models_py3 import ValidationStatus from ._models_py3 import VirtualHardDiskStatus from ._models_py3 import VirtualHardDiskStatusProvisioningStatus from ._models_py3 import VirtualHardDisks @@ -105,34 +185,93 @@ from ._models_py3 import VirtualMachineInstanceUpdateProperties from ._models_py3 import VirtualMachineInstanceUpdateRequest from ._models_py3 import VirtualMachineInstanceView +from ._models_py3 import VirtualSwitchConfigurationOverrides from ._azure_stack_hci_client_enums import ActionType +from ._azure_stack_hci_client_enums import ArcSettingAggregateState +from ._azure_stack_hci_client_enums import AvailabilityType from ._azure_stack_hci_client_enums import CloudInitDataSource +from ._azure_stack_hci_client_enums import ClusterNodeType +from ._azure_stack_hci_client_enums import ComplianceAssignmentType +from ._azure_stack_hci_client_enums import ComplianceStatus +from ._azure_stack_hci_client_enums import ConnectivityStatus from ._azure_stack_hci_client_enums import CreatedByType +from ._azure_stack_hci_client_enums import DeploymentMode +from ._azure_stack_hci_client_enums import DiagnosticLevel from ._azure_stack_hci_client_enums import DiskFileFormat from ._azure_stack_hci_client_enums import ExtendedLocationTypes +from ._azure_stack_hci_client_enums import ExtensionAggregateState +from ._azure_stack_hci_client_enums import ExtensionManagedBy +from ._azure_stack_hci_client_enums import HealthState from ._azure_stack_hci_client_enums import HyperVGeneration from ._azure_stack_hci_client_enums import IPPoolTypeEnum +from ._azure_stack_hci_client_enums import ImdsAttestation from ._azure_stack_hci_client_enums import IpAllocationMethodEnum +from ._azure_stack_hci_client_enums import ManagedServiceIdentityType +from ._azure_stack_hci_client_enums import NodeArcState +from ._azure_stack_hci_client_enums import NodeExtensionState +from ._azure_stack_hci_client_enums import OemActivation from ._azure_stack_hci_client_enums import OperatingSystemTypes from ._azure_stack_hci_client_enums import Origin from ._azure_stack_hci_client_enums import PowerStateEnum from ._azure_stack_hci_client_enums import ProvisioningAction +from ._azure_stack_hci_client_enums import ProvisioningState from ._azure_stack_hci_client_enums import ProvisioningStateEnum +from ._azure_stack_hci_client_enums import RebootRequirement from ._azure_stack_hci_client_enums import SecurityTypes +from ._azure_stack_hci_client_enums import ServiceName +from ._azure_stack_hci_client_enums import Severity +from ._azure_stack_hci_client_enums import SoftwareAssuranceIntent +from ._azure_stack_hci_client_enums import SoftwareAssuranceStatus +from ._azure_stack_hci_client_enums import State from ._azure_stack_hci_client_enums import Status from ._azure_stack_hci_client_enums import StatusLevelTypes from ._azure_stack_hci_client_enums import StatusTypes +from ._azure_stack_hci_client_enums import UpdateRunPropertiesState +from ._azure_stack_hci_client_enums import UpdateSummariesPropertiesState from ._azure_stack_hci_client_enums import VmSizeEnum +from ._azure_stack_hci_client_enums import WindowsServerSubscription from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ + "AdapterPropertyOverrides", + "ArcConnectivityProperties", + "ArcIdentityResponse", + "ArcSetting", + "ArcSettingList", + "ArcSettingsPatch", + "Cluster", + "ClusterDesiredProperties", + "ClusterIdentityResponse", + "ClusterList", + "ClusterNode", + "ClusterPatch", + "ClusterReportedProperties", + "DefaultExtensionDetails", + "DeploymentCluster", + "DeploymentConfiguration", + "DeploymentData", + "DeploymentSecuritySettings", + "DeploymentSetting", + "DeploymentSettingListResult", + "DeploymentStatus", + "DeploymentStep", + "DeviceConfiguration", + "EdgeDevice", + "EdgeDeviceListResult", "ErrorAdditionalInfo", "ErrorDetail", "ErrorResponse", "ExtendedLocation", + "Extension", + "ExtensionInstanceView", + "ExtensionInstanceViewStatus", + "ExtensionList", + "ExtensionPatch", + "ExtensionPatchParameters", + "ExtensionUpgradeParameters", "GalleryDiskImage", "GalleryImageIdentifier", "GalleryImageStatus", @@ -149,6 +288,7 @@ "GuestAgentList", "GuestCredential", "HardwareProfileUpdate", + "HostNetwork", "HttpProxyConfiguration", "HybridIdentityMetadata", "HybridIdentityMetadataList", @@ -158,8 +298,12 @@ "IPPool", "IPPoolInfo", "Identity", + "InfrastructureNetwork", "InstanceViewStatus", + "Intents", "InterfaceDNSSettings", + "IpPools", + "IsolatedVmAttestationConfiguration", "LogicalNetworkPropertiesDhcpOptions", "LogicalNetworkStatus", "LogicalNetworkStatusProvisioningStatus", @@ -179,29 +323,72 @@ "NetworkInterfacesUpdateRequest", "NetworkProfileUpdate", "NetworkProfileUpdateNetworkInterfacesItem", + "NicDetail", + "Observability", + "Offer", + "OfferList", "Operation", "OperationDisplay", "OperationListResult", + "OptionalServices", "OsProfileUpdate", "OsProfileUpdateLinuxConfiguration", "OsProfileUpdateWindowsConfiguration", + "PackageVersionInfo", + "PasswordCredential", + "PerNodeExtensionState", + "PerNodeState", + "PhysicalNodes", + "PrecheckResult", + "PrecheckResultTags", "ProxyResource", + "Publisher", + "PublisherList", + "QosPolicyOverrides", + "RawCertificateData", + "ReportedProperties", "Resource", "Route", "RouteTable", + "ScaleUnits", + "SecurityComplianceStatus", + "SecuritySetting", + "SecuritySettingListResult", + "ServiceConfiguration", + "Sku", + "SkuList", + "SkuMappings", + "SoftwareAssuranceChangeRequest", + "SoftwareAssuranceChangeRequestProperties", + "SoftwareAssuranceProperties", "SshConfiguration", "SshPublicKey", + "Step", + "Storage", "StorageContainerStatus", "StorageContainerStatusProvisioningStatus", "StorageContainers", "StorageContainersListResult", "StorageContainersUpdateRequest", + "StorageNetworks", "StorageProfileUpdate", "StorageProfileUpdateDataDisksItem", "Subnet", "SubnetPropertiesFormatIpConfigurationReferencesItem", "SystemData", "TrackedResource", + "Update", + "UpdateList", + "UpdatePrerequisite", + "UpdateRun", + "UpdateRunList", + "UpdateSummaries", + "UpdateSummariesList", + "UploadCertificateRequest", + "UserAssignedIdentity", + "ValidateRequest", + "ValidateResponse", + "ValidationStatus", "VirtualHardDiskStatus", "VirtualHardDiskStatusProvisioningStatus", "VirtualHardDisks", @@ -228,24 +415,51 @@ "VirtualMachineInstanceUpdateProperties", "VirtualMachineInstanceUpdateRequest", "VirtualMachineInstanceView", + "VirtualSwitchConfigurationOverrides", "ActionType", + "ArcSettingAggregateState", + "AvailabilityType", "CloudInitDataSource", + "ClusterNodeType", + "ComplianceAssignmentType", + "ComplianceStatus", + "ConnectivityStatus", "CreatedByType", + "DeploymentMode", + "DiagnosticLevel", "DiskFileFormat", "ExtendedLocationTypes", + "ExtensionAggregateState", + "ExtensionManagedBy", + "HealthState", "HyperVGeneration", "IPPoolTypeEnum", + "ImdsAttestation", "IpAllocationMethodEnum", + "ManagedServiceIdentityType", + "NodeArcState", + "NodeExtensionState", + "OemActivation", "OperatingSystemTypes", "Origin", "PowerStateEnum", "ProvisioningAction", + "ProvisioningState", "ProvisioningStateEnum", + "RebootRequirement", "SecurityTypes", + "ServiceName", + "Severity", + "SoftwareAssuranceIntent", + "SoftwareAssuranceStatus", + "State", "Status", "StatusLevelTypes", "StatusTypes", + "UpdateRunPropertiesState", + "UpdateSummariesPropertiesState", "VmSizeEnum", + "WindowsServerSubscription", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/models/_azure_stack_hci_client_enums.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/models/_azure_stack_hci_client_enums.py index 932688d055e5..9b97cd432773 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/models/_azure_stack_hci_client_enums.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/models/_azure_stack_hci_client_enums.py @@ -16,6 +16,37 @@ class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): INTERNAL = "Internal" +class ArcSettingAggregateState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Aggregate state of Arc agent across the nodes in this HCI cluster.""" + + NOT_SPECIFIED = "NotSpecified" + ERROR = "Error" + SUCCEEDED = "Succeeded" + CANCELED = "Canceled" + FAILED = "Failed" + CONNECTED = "Connected" + DISCONNECTED = "Disconnected" + DELETED = "Deleted" + CREATING = "Creating" + UPDATING = "Updating" + DELETING = "Deleting" + MOVING = "Moving" + PARTIALLY_SUCCEEDED = "PartiallySucceeded" + PARTIALLY_CONNECTED = "PartiallyConnected" + IN_PROGRESS = "InProgress" + ACCEPTED = "Accepted" + PROVISIONING = "Provisioning" + DISABLE_IN_PROGRESS = "DisableInProgress" + + +class AvailabilityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates the way the update content can be downloaded.""" + + LOCAL = "Local" + ONLINE = "Online" + NOTIFY = "Notify" + + class CloudInitDataSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Datasource for the gallery image when provisioning with cloud-init [NoCloud, Azure].""" @@ -23,6 +54,45 @@ class CloudInitDataSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): AZURE = "Azure" +class ClusterNodeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The node type of all the nodes of the cluster.""" + + FIRST_PARTY = "FirstParty" + THIRD_PARTY = "ThirdParty" + + +class ComplianceAssignmentType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Represents the compliance assignment type of a resource.""" + + AUDIT = "Audit" + """Report on the state of the machine, but don't make changes.""" + APPLY_AND_AUTO_CORRECT = "ApplyAndAutoCorrect" + """Applied to the machine. If it drifts, the local service inside the machine makes a correction + at the next evaluation.""" + + +class ComplianceStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Represents the compliance status of a resource.""" + + COMPLIANT = "Compliant" + """The resource is compliant""" + NON_COMPLIANT = "NonCompliant" + """The resource is non-compliant""" + PENDING = "Pending" + """The resource compliance status is pending""" + + +class ConnectivityStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Overall connectivity status for the cluster resource.""" + + NOT_YET_REGISTERED = "NotYetRegistered" + CONNECTED = "Connected" + NOT_CONNECTED_RECENTLY = "NotConnectedRecently" + PARTIALLY_CONNECTED = "PartiallyConnected" + DISCONNECTED = "Disconnected" + NOT_SPECIFIED = "NotSpecified" + + class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of identity that created the resource.""" @@ -32,6 +102,23 @@ class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): KEY = "Key" +class DeploymentMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The deployment mode for cluster deployment.""" + + VALIDATE = "Validate" + """Validate deployment settings for cluster.""" + DEPLOY = "Deploy" + """Deploy cluster using deployment settings.""" + + +class DiagnosticLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Desired level of diagnostic data emitted by the cluster.""" + + OFF = "Off" + BASIC = "Basic" + ENHANCED = "Enhanced" + + class DiskFileFormat(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The format of the actual VHD file [vhd, vhdx].""" @@ -45,6 +132,47 @@ class ExtendedLocationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): CUSTOM_LOCATION = "CustomLocation" +class ExtensionAggregateState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Aggregate state of Arc Extensions across the nodes in this HCI cluster.""" + + NOT_SPECIFIED = "NotSpecified" + ERROR = "Error" + SUCCEEDED = "Succeeded" + CANCELED = "Canceled" + FAILED = "Failed" + CONNECTED = "Connected" + DISCONNECTED = "Disconnected" + DELETED = "Deleted" + CREATING = "Creating" + UPDATING = "Updating" + DELETING = "Deleting" + MOVING = "Moving" + PARTIALLY_SUCCEEDED = "PartiallySucceeded" + PARTIALLY_CONNECTED = "PartiallyConnected" + IN_PROGRESS = "InProgress" + ACCEPTED = "Accepted" + PROVISIONING = "Provisioning" + UPGRADE_FAILED_ROLLBACK_SUCCEEDED = "UpgradeFailedRollbackSucceeded" + + +class ExtensionManagedBy(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates if the extension is managed by azure or the user.""" + + AZURE = "Azure" + USER = "User" + + +class HealthState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """HealthState.""" + + UNKNOWN = "Unknown" + SUCCESS = "Success" + FAILURE = "Failure" + WARNING = "Warning" + ERROR = "Error" + IN_PROGRESS = "InProgress" + + class HyperVGeneration(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The hypervisor generation of the Virtual Machine [V1, V2].""" @@ -52,6 +180,13 @@ class HyperVGeneration(str, Enum, metaclass=CaseInsensitiveEnumMeta): V2 = "V2" +class ImdsAttestation(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """IMDS attestation status of the cluster.""" + + DISABLED = "Disabled" + ENABLED = "Enabled" + + class IpAllocationMethodEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): """IPAllocationMethod - The IP address allocation method. Possible values include: 'Static', 'Dynamic'. @@ -68,6 +203,69 @@ class IPPoolTypeEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): VIPPOOL = "vippool" +class ManagedServiceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of managed service identity (where both SystemAssigned and UserAssigned types are + allowed). + """ + + NONE = "None" + SYSTEM_ASSIGNED = "SystemAssigned" + USER_ASSIGNED = "UserAssigned" + SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" + + +class NodeArcState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of Arc agent in this node.""" + + NOT_SPECIFIED = "NotSpecified" + ERROR = "Error" + SUCCEEDED = "Succeeded" + CANCELED = "Canceled" + FAILED = "Failed" + CONNECTED = "Connected" + DISCONNECTED = "Disconnected" + DELETED = "Deleted" + CREATING = "Creating" + UPDATING = "Updating" + DELETING = "Deleting" + MOVING = "Moving" + PARTIALLY_SUCCEEDED = "PartiallySucceeded" + PARTIALLY_CONNECTED = "PartiallyConnected" + IN_PROGRESS = "InProgress" + ACCEPTED = "Accepted" + PROVISIONING = "Provisioning" + DISABLE_IN_PROGRESS = "DisableInProgress" + + +class NodeExtensionState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of Arc Extension in this node.""" + + NOT_SPECIFIED = "NotSpecified" + ERROR = "Error" + SUCCEEDED = "Succeeded" + CANCELED = "Canceled" + FAILED = "Failed" + CONNECTED = "Connected" + DISCONNECTED = "Disconnected" + DELETED = "Deleted" + CREATING = "Creating" + UPDATING = "Updating" + DELETING = "Deleting" + MOVING = "Moving" + PARTIALLY_SUCCEEDED = "PartiallySucceeded" + PARTIALLY_CONNECTED = "PartiallyConnected" + IN_PROGRESS = "InProgress" + ACCEPTED = "Accepted" + PROVISIONING = "Provisioning" + + +class OemActivation(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """OEM activation status of the cluster.""" + + DISABLED = "Disabled" + ENABLED = "Enabled" + + class OperatingSystemTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Operating system type that the gallery image uses [Windows, Linux].""" @@ -105,6 +303,29 @@ class ProvisioningAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): REPAIR = "repair" +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the ArcSetting proxy resource.""" + + NOT_SPECIFIED = "NotSpecified" + ERROR = "Error" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + CANCELED = "Canceled" + CONNECTED = "Connected" + DISCONNECTED = "Disconnected" + DELETED = "Deleted" + CREATING = "Creating" + UPDATING = "Updating" + DELETING = "Deleting" + MOVING = "Moving" + PARTIALLY_SUCCEEDED = "PartiallySucceeded" + PARTIALLY_CONNECTED = "PartiallyConnected" + IN_PROGRESS = "InProgress" + ACCEPTED = "Accepted" + PROVISIONING = "Provisioning" + DISABLE_IN_PROGRESS = "DisableInProgress" + + class ProvisioningStateEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Provisioning state of the gallery image.""" @@ -116,6 +337,14 @@ class ProvisioningStateEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): CANCELED = "Canceled" +class RebootRequirement(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """RebootRequirement.""" + + UNKNOWN = "Unknown" + TRUE = "True" + FALSE = "False" + + class SecurityTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the SecurityType of the virtual machine. EnableTPM and SecureBootEnabled must be set to true for SecurityType to function. @@ -125,9 +354,76 @@ class SecurityTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): CONFIDENTIAL_VM = "ConfidentialVM" +class ServiceName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Name of the service.""" + + WAC = "WAC" + + +class Severity(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Severity of the result (Critical, Warning, Informational, Hidden). This answers how important + the result is. Critical is the only update-blocking severity. + """ + + CRITICAL = "Critical" + WARNING = "Warning" + INFORMATIONAL = "Informational" + HIDDEN = "Hidden" + + +class SoftwareAssuranceIntent(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Customer Intent for Software Assurance Benefit.""" + + ENABLE = "Enable" + DISABLE = "Disable" + + +class SoftwareAssuranceStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Status of the Software Assurance for the cluster.""" + + ENABLED = "Enabled" + DISABLED = "Disabled" + + +class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the update as it relates to this stamp.""" + + HAS_PREREQUISITE = "HasPrerequisite" + OBSOLETE = "Obsolete" + READY = "Ready" + NOT_APPLICABLE_BECAUSE_ANOTHER_UPDATE_IS_IN_PROGRESS = "NotApplicableBecauseAnotherUpdateIsInProgress" + PREPARING = "Preparing" + INSTALLING = "Installing" + INSTALLED = "Installed" + PREPARATION_FAILED = "PreparationFailed" + INSTALLATION_FAILED = "InstallationFailed" + INVALID = "Invalid" + RECALLED = "Recalled" + DOWNLOADING = "Downloading" + DOWNLOAD_FAILED = "DownloadFailed" + HEALTH_CHECKING = "HealthChecking" + HEALTH_CHECK_FAILED = "HealthCheckFailed" + READY_TO_INSTALL = "ReadyToInstall" + SCAN_IN_PROGRESS = "ScanInProgress" + SCAN_FAILED = "ScanFailed" + ADDITIONAL_CONTENT_REQUIRED = "AdditionalContentRequired" + + class Status(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The status of the operation performed on the gallery image [Succeeded, Failed, InProgress].""" + """Status of the cluster agent.""" + NOT_YET_REGISTERED = "NotYetRegistered" + CONNECTED_RECENTLY = "ConnectedRecently" + NOT_CONNECTED_RECENTLY = "NotConnectedRecently" + DISCONNECTED = "Disconnected" + ERROR = "Error" + NOT_SPECIFIED = "NotSpecified" + VALIDATION_IN_PROGRESS = "ValidationInProgress" + VALIDATION_SUCCESS = "ValidationSuccess" + VALIDATION_FAILED = "ValidationFailed" + DEPLOYMENT_IN_PROGRESS = "DeploymentInProgress" + DEPLOYMENT_FAILED = "DeploymentFailed" + DEPLOYMENT_SUCCESS = "DeploymentSuccess" SUCCEEDED = "Succeeded" FAILED = "Failed" IN_PROGRESS = "InProgress" @@ -149,6 +445,28 @@ class StatusTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): FAILED = "Failed" +class UpdateRunPropertiesState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the update run.""" + + UNKNOWN = "Unknown" + SUCCEEDED = "Succeeded" + IN_PROGRESS = "InProgress" + FAILED = "Failed" + + +class UpdateSummariesPropertiesState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Overall update state of the stamp.""" + + UNKNOWN = "Unknown" + APPLIED_SUCCESSFULLY = "AppliedSuccessfully" + UPDATE_AVAILABLE = "UpdateAvailable" + UPDATE_IN_PROGRESS = "UpdateInProgress" + UPDATE_FAILED = "UpdateFailed" + NEEDS_ATTENTION = "NeedsAttention" + PREPARATION_IN_PROGRESS = "PreparationInProgress" + PREPARATION_FAILED = "PreparationFailed" + + class VmSizeEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): """VmSizeEnum.""" @@ -175,3 +493,10 @@ class VmSizeEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): STANDARD_NV12 = "Standard_NV12" STANDARD_K8_S5_V1 = "Standard_K8S5_v1" CUSTOM = "Custom" + + +class WindowsServerSubscription(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Desired state of Windows Server Subscription.""" + + DISABLED = "Disabled" + ENABLED = "Enabled" diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/models/_models_py3.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/models/_models_py3.py index ba7201b5ba98..af2719d3bba6 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/models/_models_py3.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/models/_models_py3.py @@ -9,214 +9,216 @@ import datetime import sys -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union +from typing import Any, Dict, List, Literal, Optional, TYPE_CHECKING, Union from .. import _serialization -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from .. import models as _models - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorDetail(_serialization.Model): - """The error detail. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.azurestackhci.models.ErrorDetail] - :ivar additional_info: The error additional info. - :vartype additional_info: list[~azure.mgmt.azurestackhci.models.ErrorAdditionalInfo] +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object + + +class AdapterPropertyOverrides(_serialization.Model): + """The AdapterPropertyOverrides of a cluster. + + :ivar jumbo_packet: This parameter should only be modified based on your OEM guidance. Do not + modify this parameter without OEM validation. + :vartype jumbo_packet: str + :ivar network_direct: This parameter should only be modified based on your OEM guidance. Do not + modify this parameter without OEM validation. + :vartype network_direct: str + :ivar network_direct_technology: This parameter should only be modified based on your OEM + guidance. Do not modify this parameter without OEM validation. Expected values are 'iWARP', + 'RoCEv2', 'RoCE'. + :vartype network_direct_technology: str """ - _validation = { - "code": {"readonly": True}, - "message": {"readonly": True}, - "target": {"readonly": True}, - "details": {"readonly": True}, - "additional_info": {"readonly": True}, - } - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "details": {"key": "details", "type": "[ErrorDetail]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, + "jumbo_packet": {"key": "jumboPacket", "type": "str"}, + "network_direct": {"key": "networkDirect", "type": "str"}, + "network_direct_technology": {"key": "networkDirectTechnology", "type": "str"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__( + self, + *, + jumbo_packet: Optional[str] = None, + network_direct: Optional[str] = None, + network_direct_technology: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword jumbo_packet: This parameter should only be modified based on your OEM guidance. Do + not modify this parameter without OEM validation. + :paramtype jumbo_packet: str + :keyword network_direct: This parameter should only be modified based on your OEM guidance. Do + not modify this parameter without OEM validation. + :paramtype network_direct: str + :keyword network_direct_technology: This parameter should only be modified based on your OEM + guidance. Do not modify this parameter without OEM validation. Expected values are 'iWARP', + 'RoCEv2', 'RoCE'. + :paramtype network_direct_technology: str + """ super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None + self.jumbo_packet = jumbo_packet + self.network_direct = network_direct + self.network_direct_technology = network_direct_technology -class ErrorResponse(_serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed - operations. (This also follows the OData error response format.). +class ArcConnectivityProperties(_serialization.Model): + """Connectivity related configuration required by arc server. - :ivar error: The error object. - :vartype error: ~azure.mgmt.azurestackhci.models.ErrorDetail + :ivar enabled: True indicates ARC connectivity is enabled. + :vartype enabled: bool + :ivar service_configurations: Service configurations associated with the connectivity resource. + They are only processed by the server if 'enabled' property is set to 'true'. + :vartype service_configurations: list[~azure.mgmt.azurestackhci.models.ServiceConfiguration] """ _attribute_map = { - "error": {"key": "error", "type": "ErrorDetail"}, + "enabled": {"key": "enabled", "type": "bool"}, + "service_configurations": {"key": "serviceConfigurations", "type": "[ServiceConfiguration]"}, } - def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: + def __init__( + self, + *, + enabled: Optional[bool] = None, + service_configurations: Optional[List["_models.ServiceConfiguration"]] = None, + **kwargs: Any + ) -> None: """ - :keyword error: The error object. - :paramtype error: ~azure.mgmt.azurestackhci.models.ErrorDetail + :keyword enabled: True indicates ARC connectivity is enabled. + :paramtype enabled: bool + :keyword service_configurations: Service configurations associated with the connectivity + resource. They are only processed by the server if 'enabled' property is set to 'true'. + :paramtype service_configurations: list[~azure.mgmt.azurestackhci.models.ServiceConfiguration] """ super().__init__(**kwargs) - self.error = error + self.enabled = enabled + self.service_configurations = service_configurations -class ExtendedLocation(_serialization.Model): - """The complex type of the extended location. +class ArcIdentityResponse(_serialization.Model): + """ArcIdentity details. - :ivar name: The name of the extended location. - :vartype name: str - :ivar type: The type of the extended location. "CustomLocation" - :vartype type: str or ~azure.mgmt.azurestackhci.models.ExtendedLocationTypes + :ivar arc_application_client_id: + :vartype arc_application_client_id: str + :ivar arc_application_tenant_id: + :vartype arc_application_tenant_id: str + :ivar arc_service_principal_object_id: + :vartype arc_service_principal_object_id: str + :ivar arc_application_object_id: + :vartype arc_application_object_id: str """ _attribute_map = { - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, + "arc_application_client_id": {"key": "properties.arcApplicationClientId", "type": "str"}, + "arc_application_tenant_id": {"key": "properties.arcApplicationTenantId", "type": "str"}, + "arc_service_principal_object_id": {"key": "properties.arcServicePrincipalObjectId", "type": "str"}, + "arc_application_object_id": {"key": "properties.arcApplicationObjectId", "type": "str"}, } def __init__( self, *, - name: Optional[str] = None, - type: Optional[Union[str, "_models.ExtendedLocationTypes"]] = None, + arc_application_client_id: Optional[str] = None, + arc_application_tenant_id: Optional[str] = None, + arc_service_principal_object_id: Optional[str] = None, + arc_application_object_id: Optional[str] = None, **kwargs: Any ) -> None: """ - :keyword name: The name of the extended location. - :paramtype name: str - :keyword type: The type of the extended location. "CustomLocation" - :paramtype type: str or ~azure.mgmt.azurestackhci.models.ExtendedLocationTypes + :keyword arc_application_client_id: + :paramtype arc_application_client_id: str + :keyword arc_application_tenant_id: + :paramtype arc_application_tenant_id: str + :keyword arc_service_principal_object_id: + :paramtype arc_service_principal_object_id: str + :keyword arc_application_object_id: + :paramtype arc_application_object_id: str """ super().__init__(**kwargs) - self.name = name - self.type = type + self.arc_application_client_id = arc_application_client_id + self.arc_application_tenant_id = arc_application_tenant_id + self.arc_service_principal_object_id = arc_service_principal_object_id + self.arc_application_object_id = arc_application_object_id -class GalleryDiskImage(_serialization.Model): - """This is the disk image base class. +class Resource(_serialization.Model): + """Common fields that are returned in the response for all Azure Resource Manager resources. Variables are only populated by the server, and will be ignored when sending a request. - :ivar size_in_mb: This property indicates the size of the VHD to be created. - :vartype size_in_mb: int + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.azurestackhci.models.SystemData """ _validation = { - "size_in_mb": {"readonly": True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { - "size_in_mb": {"key": "sizeInMB", "type": "int"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.size_in_mb = None + self.id = None + self.name = None + self.type = None + self.system_data = None -class GalleryImageIdentifier(_serialization.Model): - """This is the gallery image definition identifier. +class ProxyResource(Resource): + """The resource model definition for a Azure Resource Manager proxy resource. It will not have + tags and a location. - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar publisher: The name of the gallery image definition publisher. Required. - :vartype publisher: str - :ivar offer: The name of the gallery image definition offer. Required. - :vartype offer: str - :ivar sku: The name of the gallery image definition SKU. Required. - :vartype sku: str + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.azurestackhci.models.SystemData """ - _validation = { - "publisher": {"required": True}, - "offer": {"required": True}, - "sku": {"required": True}, - } - - _attribute_map = { - "publisher": {"key": "publisher", "type": "str"}, - "offer": {"key": "offer", "type": "str"}, - "sku": {"key": "sku", "type": "str"}, - } - - def __init__(self, *, publisher: str, offer: str, sku: str, **kwargs: Any) -> None: - """ - :keyword publisher: The name of the gallery image definition publisher. Required. - :paramtype publisher: str - :keyword offer: The name of the gallery image definition offer. Required. - :paramtype offer: str - :keyword sku: The name of the gallery image definition SKU. Required. - :paramtype sku: str - """ - super().__init__(**kwargs) - self.publisher = publisher - self.offer = offer - self.sku = sku - -class Resource(_serialization.Model): - """Common fields that are returned in the response for all Azure Resource Manager resources. +class ArcSetting(ProxyResource): # pylint: disable=too-many-instance-attributes + """ArcSetting details. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -226,6 +228,33 @@ class Resource(_serialization.Model): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.azurestackhci.models.SystemData + :ivar provisioning_state: Provisioning state of the ArcSetting proxy resource. Known values + are: "NotSpecified", "Error", "Succeeded", "Failed", "Canceled", "Connected", "Disconnected", + "Deleted", "Creating", "Updating", "Deleting", "Moving", "PartiallySucceeded", + "PartiallyConnected", "InProgress", "Accepted", "Provisioning", and "DisableInProgress". + :vartype provisioning_state: str or ~azure.mgmt.azurestackhci.models.ProvisioningState + :ivar arc_instance_resource_group: The resource group that hosts the Arc agents, ie. Hybrid + Compute Machine resources. + :vartype arc_instance_resource_group: str + :ivar arc_application_client_id: App id of arc AAD identity. + :vartype arc_application_client_id: str + :ivar arc_application_tenant_id: Tenant id of arc AAD identity. + :vartype arc_application_tenant_id: str + :ivar arc_service_principal_object_id: Object id of arc AAD service principal. + :vartype arc_service_principal_object_id: str + :ivar arc_application_object_id: Object id of arc AAD identity. + :vartype arc_application_object_id: str + :ivar aggregate_state: Aggregate state of Arc agent across the nodes in this HCI cluster. Known + values are: "NotSpecified", "Error", "Succeeded", "Canceled", "Failed", "Connected", + "Disconnected", "Deleted", "Creating", "Updating", "Deleting", "Moving", "PartiallySucceeded", + "PartiallyConnected", "InProgress", "Accepted", "Provisioning", and "DisableInProgress". + :vartype aggregate_state: str or ~azure.mgmt.azurestackhci.models.ArcSettingAggregateState + :ivar per_node_details: State of Arc agent in each of the nodes. + :vartype per_node_details: list[~azure.mgmt.azurestackhci.models.PerNodeState] + :ivar connectivity_properties: contains connectivity related configuration for ARC resources. + :vartype connectivity_properties: JSON + :ivar default_extensions: Properties for each of the default extensions category. + :vartype default_extensions: list[~azure.mgmt.azurestackhci.models.DefaultExtensionDetails] """ _validation = { @@ -233,6 +262,10 @@ class Resource(_serialization.Model): "name": {"readonly": True}, "type": {"readonly": True}, "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "aggregate_state": {"readonly": True}, + "per_node_details": {"readonly": True}, + "default_extensions": {"readonly": True}, } _attribute_map = { @@ -240,15 +273,113 @@ class Resource(_serialization.Model): "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "arc_instance_resource_group": {"key": "properties.arcInstanceResourceGroup", "type": "str"}, + "arc_application_client_id": {"key": "properties.arcApplicationClientId", "type": "str"}, + "arc_application_tenant_id": {"key": "properties.arcApplicationTenantId", "type": "str"}, + "arc_service_principal_object_id": {"key": "properties.arcServicePrincipalObjectId", "type": "str"}, + "arc_application_object_id": {"key": "properties.arcApplicationObjectId", "type": "str"}, + "aggregate_state": {"key": "properties.aggregateState", "type": "str"}, + "per_node_details": {"key": "properties.perNodeDetails", "type": "[PerNodeState]"}, + "connectivity_properties": {"key": "properties.connectivityProperties", "type": "object"}, + "default_extensions": {"key": "properties.defaultExtensions", "type": "[DefaultExtensionDetails]"}, + } + + def __init__( + self, + *, + arc_instance_resource_group: Optional[str] = None, + arc_application_client_id: Optional[str] = None, + arc_application_tenant_id: Optional[str] = None, + arc_service_principal_object_id: Optional[str] = None, + arc_application_object_id: Optional[str] = None, + connectivity_properties: Optional[JSON] = None, + **kwargs: Any + ) -> None: + """ + :keyword arc_instance_resource_group: The resource group that hosts the Arc agents, ie. Hybrid + Compute Machine resources. + :paramtype arc_instance_resource_group: str + :keyword arc_application_client_id: App id of arc AAD identity. + :paramtype arc_application_client_id: str + :keyword arc_application_tenant_id: Tenant id of arc AAD identity. + :paramtype arc_application_tenant_id: str + :keyword arc_service_principal_object_id: Object id of arc AAD service principal. + :paramtype arc_service_principal_object_id: str + :keyword arc_application_object_id: Object id of arc AAD identity. + :paramtype arc_application_object_id: str + :keyword connectivity_properties: contains connectivity related configuration for ARC + resources. + :paramtype connectivity_properties: JSON + """ + super().__init__(**kwargs) + self.provisioning_state = None + self.arc_instance_resource_group = arc_instance_resource_group + self.arc_application_client_id = arc_application_client_id + self.arc_application_tenant_id = arc_application_tenant_id + self.arc_service_principal_object_id = arc_service_principal_object_id + self.arc_application_object_id = arc_application_object_id + self.aggregate_state = None + self.per_node_details = None + self.connectivity_properties = connectivity_properties + self.default_extensions = None + + +class ArcSettingList(_serialization.Model): + """List of ArcSetting proxy resources for the HCI cluster. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of ArcSetting proxy resources. + :vartype value: list[~azure.mgmt.azurestackhci.models.ArcSetting] + :ivar next_link: Link to the next set of results. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[ArcSetting]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.system_data = None + self.value = None + self.next_link = None + + +class ArcSettingsPatch(_serialization.Model): + """ArcSetting details to update. + + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar connectivity_properties: contains connectivity related configuration for ARC resources. + :vartype connectivity_properties: JSON + """ + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + "connectivity_properties": {"key": "properties.connectivityProperties", "type": "object"}, + } + + def __init__( + self, *, tags: Optional[Dict[str, str]] = None, connectivity_properties: Optional[JSON] = None, **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword connectivity_properties: contains connectivity related configuration for ARC + resources. + :paramtype connectivity_properties: JSON + """ + super().__init__(**kwargs) + self.tags = tags + self.connectivity_properties = connectivity_properties class TrackedResource(Resource): @@ -257,10 +388,10 @@ class TrackedResource(Resource): Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -305,15 +436,15 @@ def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kw self.location = location -class GalleryImages(TrackedResource): # pylint: disable=too-many-instance-attributes - """The gallery images resource definition. +class Cluster(TrackedResource): # pylint: disable=too-many-instance-attributes + """Cluster details. 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. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -327,31 +458,73 @@ class GalleryImages(TrackedResource): # pylint: disable=too-many-instance-attri :vartype tags: dict[str, str] :ivar location: The geo-location where the resource lives. Required. :vartype location: str - :ivar extended_location: The extendedLocation of the resource. - :vartype extended_location: ~azure.mgmt.azurestackhci.models.ExtendedLocation - :ivar container_id: Storage ContainerID of the storage container to be used for gallery image. - :vartype container_id: str - :ivar image_path: location of the image the gallery image should be created from. - :vartype image_path: str - :ivar os_type: Operating system type that the gallery image uses [Windows, Linux]. Known values - are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.azurestackhci.models.OperatingSystemTypes - :ivar cloud_init_data_source: Datasource for the gallery image when provisioning with - cloud-init [NoCloud, Azure]. Known values are: "NoCloud" and "Azure". - :vartype cloud_init_data_source: str or ~azure.mgmt.azurestackhci.models.CloudInitDataSource - :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine [V1, V2]. Known - values are: "V1" and "V2". - :vartype hyper_v_generation: str or ~azure.mgmt.azurestackhci.models.HyperVGeneration - :ivar identifier: This is the gallery image definition identifier. - :vartype identifier: ~azure.mgmt.azurestackhci.models.GalleryImageIdentifier - :ivar version: Specifies information about the gallery image version that you want to create or - update. - :vartype version: ~azure.mgmt.azurestackhci.models.GalleryImageVersion - :ivar provisioning_state: Provisioning state of the gallery image. Known values are: - "Succeeded", "Failed", "InProgress", "Accepted", "Deleting", and "Canceled". - :vartype provisioning_state: str or ~azure.mgmt.azurestackhci.models.ProvisioningStateEnum - :ivar status: The observed state of gallery images. - :vartype status: ~azure.mgmt.azurestackhci.models.GalleryImageStatus + :ivar provisioning_state: Provisioning state. Known values are: "NotSpecified", "Error", + "Succeeded", "Failed", "Canceled", "Connected", "Disconnected", "Deleted", "Creating", + "Updating", "Deleting", "Moving", "PartiallySucceeded", "PartiallyConnected", "InProgress", + "Accepted", "Provisioning", and "DisableInProgress". + :vartype provisioning_state: str or ~azure.mgmt.azurestackhci.models.ProvisioningState + :ivar status: Status of the cluster agent. Known values are: "NotYetRegistered", + "ConnectedRecently", "NotConnectedRecently", "Disconnected", "Error", "NotSpecified", + "ValidationInProgress", "ValidationSuccess", "ValidationFailed", "DeploymentInProgress", + "DeploymentFailed", "DeploymentSuccess", "Succeeded", "Failed", and "InProgress". + :vartype status: str or ~azure.mgmt.azurestackhci.models.Status + :ivar connectivity_status: Overall connectivity status for the cluster resource. Known values + are: "NotYetRegistered", "Connected", "NotConnectedRecently", "PartiallyConnected", + "Disconnected", and "NotSpecified". + :vartype connectivity_status: str or ~azure.mgmt.azurestackhci.models.ConnectivityStatus + :ivar cloud_id: Unique, immutable resource id. + :vartype cloud_id: str + :ivar cloud_management_endpoint: Endpoint configured for management from the Azure portal. + :vartype cloud_management_endpoint: str + :ivar aad_client_id: App id of cluster AAD identity. + :vartype aad_client_id: str + :ivar aad_tenant_id: Tenant id of cluster AAD identity. + :vartype aad_tenant_id: str + :ivar aad_application_object_id: Object id of cluster AAD identity. + :vartype aad_application_object_id: str + :ivar aad_service_principal_object_id: Id of cluster identity service principal. + :vartype aad_service_principal_object_id: str + :ivar software_assurance_properties: Software Assurance properties of the cluster. + :vartype software_assurance_properties: + ~azure.mgmt.azurestackhci.models.SoftwareAssuranceProperties + :ivar desired_properties: Desired properties of the cluster. + :vartype desired_properties: ~azure.mgmt.azurestackhci.models.ClusterDesiredProperties + :ivar reported_properties: Properties reported by cluster agent. + :vartype reported_properties: ~azure.mgmt.azurestackhci.models.ClusterReportedProperties + :ivar isolated_vm_attestation_configuration: Attestation configurations for isolated VM (e.g. + TVM, CVM) of the cluster. + :vartype isolated_vm_attestation_configuration: + ~azure.mgmt.azurestackhci.models.IsolatedVmAttestationConfiguration + :ivar trial_days_remaining: Number of days remaining in the trial period. + :vartype trial_days_remaining: float + :ivar billing_model: Type of billing applied to the resource. + :vartype billing_model: str + :ivar registration_timestamp: First cluster sync timestamp. + :vartype registration_timestamp: ~datetime.datetime + :ivar last_sync_timestamp: Most recent cluster sync timestamp. + :vartype last_sync_timestamp: ~datetime.datetime + :ivar last_billing_timestamp: Most recent billing meter timestamp. + :vartype last_billing_timestamp: ~datetime.datetime + :ivar service_endpoint: Region specific DataPath Endpoint of the cluster. + :vartype service_endpoint: str + :ivar resource_provider_object_id: Object id of RP Service Principal. + :vartype resource_provider_object_id: str + :ivar principal_id: The service principal ID of the system assigned identity. This property + will only be provided for a system assigned identity. + :vartype principal_id: str + :ivar tenant_id: The tenant ID of the system assigned identity. This property will only be + provided for a system assigned identity. + :vartype tenant_id: str + :ivar type_identity_type: Type of managed service identity (where both SystemAssigned and + UserAssigned types are allowed). Known values are: "None", "SystemAssigned", "UserAssigned", + and "SystemAssigned, UserAssigned". + :vartype type_identity_type: str or ~azure.mgmt.azurestackhci.models.ManagedServiceIdentityType + :ivar user_assigned_identities: The set of user assigned identities associated with the + resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. # pylint: disable=line-too-long + The dictionary values can be empty objects ({}) in requests. + :vartype user_assigned_identities: dict[str, + ~azure.mgmt.azurestackhci.models.UserAssignedIdentity] """ _validation = { @@ -362,6 +535,19 @@ class GalleryImages(TrackedResource): # pylint: disable=too-many-instance-attri "location": {"required": True}, "provisioning_state": {"readonly": True}, "status": {"readonly": True}, + "connectivity_status": {"readonly": True}, + "cloud_id": {"readonly": True}, + "reported_properties": {"readonly": True}, + "isolated_vm_attestation_configuration": {"readonly": True}, + "trial_days_remaining": {"readonly": True}, + "billing_model": {"readonly": True}, + "registration_timestamp": {"readonly": True}, + "last_sync_timestamp": {"readonly": True}, + "last_billing_timestamp": {"readonly": True}, + "service_endpoint": {"readonly": True}, + "resource_provider_object_id": {"readonly": True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, } _attribute_map = { @@ -371,31 +557,52 @@ class GalleryImages(TrackedResource): # pylint: disable=too-many-instance-attri "system_data": {"key": "systemData", "type": "SystemData"}, "tags": {"key": "tags", "type": "{str}"}, "location": {"key": "location", "type": "str"}, - "extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"}, - "container_id": {"key": "properties.containerId", "type": "str"}, - "image_path": {"key": "properties.imagePath", "type": "str"}, - "os_type": {"key": "properties.osType", "type": "str"}, - "cloud_init_data_source": {"key": "properties.cloudInitDataSource", "type": "str"}, - "hyper_v_generation": {"key": "properties.hyperVGeneration", "type": "str"}, - "identifier": {"key": "properties.identifier", "type": "GalleryImageIdentifier"}, - "version": {"key": "properties.version", "type": "GalleryImageVersion"}, "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "status": {"key": "properties.status", "type": "GalleryImageStatus"}, - } - - def __init__( + "status": {"key": "properties.status", "type": "str"}, + "connectivity_status": {"key": "properties.connectivityStatus", "type": "str"}, + "cloud_id": {"key": "properties.cloudId", "type": "str"}, + "cloud_management_endpoint": {"key": "properties.cloudManagementEndpoint", "type": "str"}, + "aad_client_id": {"key": "properties.aadClientId", "type": "str"}, + "aad_tenant_id": {"key": "properties.aadTenantId", "type": "str"}, + "aad_application_object_id": {"key": "properties.aadApplicationObjectId", "type": "str"}, + "aad_service_principal_object_id": {"key": "properties.aadServicePrincipalObjectId", "type": "str"}, + "software_assurance_properties": { + "key": "properties.softwareAssuranceProperties", + "type": "SoftwareAssuranceProperties", + }, + "desired_properties": {"key": "properties.desiredProperties", "type": "ClusterDesiredProperties"}, + "reported_properties": {"key": "properties.reportedProperties", "type": "ClusterReportedProperties"}, + "isolated_vm_attestation_configuration": { + "key": "properties.isolatedVmAttestationConfiguration", + "type": "IsolatedVmAttestationConfiguration", + }, + "trial_days_remaining": {"key": "properties.trialDaysRemaining", "type": "float"}, + "billing_model": {"key": "properties.billingModel", "type": "str"}, + "registration_timestamp": {"key": "properties.registrationTimestamp", "type": "iso-8601"}, + "last_sync_timestamp": {"key": "properties.lastSyncTimestamp", "type": "iso-8601"}, + "last_billing_timestamp": {"key": "properties.lastBillingTimestamp", "type": "iso-8601"}, + "service_endpoint": {"key": "properties.serviceEndpoint", "type": "str"}, + "resource_provider_object_id": {"key": "properties.resourceProviderObjectId", "type": "str"}, + "principal_id": {"key": "identity.principalId", "type": "str"}, + "tenant_id": {"key": "identity.tenantId", "type": "str"}, + "type_identity_type": {"key": "identity.type", "type": "str"}, + "user_assigned_identities": {"key": "identity.userAssignedIdentities", "type": "{UserAssignedIdentity}"}, + } + + def __init__( # pylint: disable=too-many-locals self, *, location: str, tags: Optional[Dict[str, str]] = None, - extended_location: Optional["_models.ExtendedLocation"] = None, - container_id: Optional[str] = None, - image_path: Optional[str] = None, - os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - cloud_init_data_source: Optional[Union[str, "_models.CloudInitDataSource"]] = None, - hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, - identifier: Optional["_models.GalleryImageIdentifier"] = None, - version: Optional["_models.GalleryImageVersion"] = None, + cloud_management_endpoint: Optional[str] = None, + aad_client_id: Optional[str] = None, + aad_tenant_id: Optional[str] = None, + aad_application_object_id: Optional[str] = None, + aad_service_principal_object_id: Optional[str] = None, + software_assurance_properties: Optional["_models.SoftwareAssuranceProperties"] = None, + desired_properties: Optional["_models.ClusterDesiredProperties"] = None, + type_identity_type: Optional[Union[str, "_models.ManagedServiceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentity"]] = None, **kwargs: Any ) -> None: """ @@ -403,282 +610,798 @@ def __init__( :paramtype tags: dict[str, str] :keyword location: The geo-location where the resource lives. Required. :paramtype location: str - :keyword extended_location: The extendedLocation of the resource. - :paramtype extended_location: ~azure.mgmt.azurestackhci.models.ExtendedLocation - :keyword container_id: Storage ContainerID of the storage container to be used for gallery - image. - :paramtype container_id: str - :keyword image_path: location of the image the gallery image should be created from. - :paramtype image_path: str - :keyword os_type: Operating system type that the gallery image uses [Windows, Linux]. Known - values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.azurestackhci.models.OperatingSystemTypes - :keyword cloud_init_data_source: Datasource for the gallery image when provisioning with - cloud-init [NoCloud, Azure]. Known values are: "NoCloud" and "Azure". - :paramtype cloud_init_data_source: str or ~azure.mgmt.azurestackhci.models.CloudInitDataSource - :keyword hyper_v_generation: The hypervisor generation of the Virtual Machine [V1, V2]. Known - values are: "V1" and "V2". - :paramtype hyper_v_generation: str or ~azure.mgmt.azurestackhci.models.HyperVGeneration - :keyword identifier: This is the gallery image definition identifier. - :paramtype identifier: ~azure.mgmt.azurestackhci.models.GalleryImageIdentifier - :keyword version: Specifies information about the gallery image version that you want to create - or update. - :paramtype version: ~azure.mgmt.azurestackhci.models.GalleryImageVersion + :keyword cloud_management_endpoint: Endpoint configured for management from the Azure portal. + :paramtype cloud_management_endpoint: str + :keyword aad_client_id: App id of cluster AAD identity. + :paramtype aad_client_id: str + :keyword aad_tenant_id: Tenant id of cluster AAD identity. + :paramtype aad_tenant_id: str + :keyword aad_application_object_id: Object id of cluster AAD identity. + :paramtype aad_application_object_id: str + :keyword aad_service_principal_object_id: Id of cluster identity service principal. + :paramtype aad_service_principal_object_id: str + :keyword software_assurance_properties: Software Assurance properties of the cluster. + :paramtype software_assurance_properties: + ~azure.mgmt.azurestackhci.models.SoftwareAssuranceProperties + :keyword desired_properties: Desired properties of the cluster. + :paramtype desired_properties: ~azure.mgmt.azurestackhci.models.ClusterDesiredProperties + :keyword type_identity_type: Type of managed service identity (where both SystemAssigned and + UserAssigned types are allowed). Known values are: "None", "SystemAssigned", "UserAssigned", + and "SystemAssigned, UserAssigned". + :paramtype type_identity_type: str or + ~azure.mgmt.azurestackhci.models.ManagedServiceIdentityType + :keyword user_assigned_identities: The set of user assigned identities associated with the + resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. # pylint: disable=line-too-long + The dictionary values can be empty objects ({}) in requests. + :paramtype user_assigned_identities: dict[str, + ~azure.mgmt.azurestackhci.models.UserAssignedIdentity] """ super().__init__(tags=tags, location=location, **kwargs) - self.extended_location = extended_location - self.container_id = container_id - self.image_path = image_path - self.os_type = os_type - self.cloud_init_data_source = cloud_init_data_source - self.hyper_v_generation = hyper_v_generation - self.identifier = identifier - self.version = version self.provisioning_state = None self.status = None + self.connectivity_status = None + self.cloud_id = None + self.cloud_management_endpoint = cloud_management_endpoint + self.aad_client_id = aad_client_id + self.aad_tenant_id = aad_tenant_id + self.aad_application_object_id = aad_application_object_id + self.aad_service_principal_object_id = aad_service_principal_object_id + self.software_assurance_properties = software_assurance_properties + self.desired_properties = desired_properties + self.reported_properties = None + self.isolated_vm_attestation_configuration = None + self.trial_days_remaining = None + self.billing_model = None + self.registration_timestamp = None + self.last_sync_timestamp = None + self.last_billing_timestamp = None + self.service_endpoint = None + self.resource_provider_object_id = None + self.principal_id = None + self.tenant_id = None + self.type_identity_type = type_identity_type + self.user_assigned_identities = user_assigned_identities -class GalleryImagesListResult(_serialization.Model): - """List of gallery images. - - Variables are only populated by the server, and will be ignored when sending a request. +class ClusterDesiredProperties(_serialization.Model): + """Desired properties of the cluster. - :ivar value: - :vartype value: list[~azure.mgmt.azurestackhci.models.GalleryImages] - :ivar next_link: Link to the next set of results. - :vartype next_link: str + :ivar windows_server_subscription: Desired state of Windows Server Subscription. Known values + are: "Disabled" and "Enabled". + :vartype windows_server_subscription: str or + ~azure.mgmt.azurestackhci.models.WindowsServerSubscription + :ivar diagnostic_level: Desired level of diagnostic data emitted by the cluster. Known values + are: "Off", "Basic", and "Enhanced". + :vartype diagnostic_level: str or ~azure.mgmt.azurestackhci.models.DiagnosticLevel """ - _validation = { - "next_link": {"readonly": True}, - } - _attribute_map = { - "value": {"key": "value", "type": "[GalleryImages]"}, - "next_link": {"key": "nextLink", "type": "str"}, + "windows_server_subscription": {"key": "windowsServerSubscription", "type": "str"}, + "diagnostic_level": {"key": "diagnosticLevel", "type": "str"}, } - def __init__(self, *, value: Optional[List["_models.GalleryImages"]] = None, **kwargs: Any) -> None: + def __init__( + self, + *, + windows_server_subscription: Optional[Union[str, "_models.WindowsServerSubscription"]] = None, + diagnostic_level: Optional[Union[str, "_models.DiagnosticLevel"]] = None, + **kwargs: Any + ) -> None: """ - :keyword value: - :paramtype value: list[~azure.mgmt.azurestackhci.models.GalleryImages] + :keyword windows_server_subscription: Desired state of Windows Server Subscription. Known + values are: "Disabled" and "Enabled". + :paramtype windows_server_subscription: str or + ~azure.mgmt.azurestackhci.models.WindowsServerSubscription + :keyword diagnostic_level: Desired level of diagnostic data emitted by the cluster. Known + values are: "Off", "Basic", and "Enhanced". + :paramtype diagnostic_level: str or ~azure.mgmt.azurestackhci.models.DiagnosticLevel """ super().__init__(**kwargs) - self.value = value - self.next_link = None + self.windows_server_subscription = windows_server_subscription + self.diagnostic_level = diagnostic_level -class GalleryImageStatus(_serialization.Model): - """The observed state of gallery images. +class ClusterIdentityResponse(_serialization.Model): + """Cluster Identity details. - :ivar error_code: GalleryImage provisioning error code. - :vartype error_code: str - :ivar error_message: Descriptive error message. - :vartype error_message: str - :ivar provisioning_status: - :vartype provisioning_status: - ~azure.mgmt.azurestackhci.models.GalleryImageStatusProvisioningStatus - :ivar download_status: The download status of the gallery image. - :vartype download_status: ~azure.mgmt.azurestackhci.models.GalleryImageStatusDownloadStatus - :ivar progress_percentage: The progress of the operation in percentage. - :vartype progress_percentage: int + :ivar aad_client_id: + :vartype aad_client_id: str + :ivar aad_tenant_id: + :vartype aad_tenant_id: str + :ivar aad_service_principal_object_id: + :vartype aad_service_principal_object_id: str + :ivar aad_application_object_id: + :vartype aad_application_object_id: str """ _attribute_map = { - "error_code": {"key": "errorCode", "type": "str"}, - "error_message": {"key": "errorMessage", "type": "str"}, - "provisioning_status": {"key": "provisioningStatus", "type": "GalleryImageStatusProvisioningStatus"}, - "download_status": {"key": "downloadStatus", "type": "GalleryImageStatusDownloadStatus"}, - "progress_percentage": {"key": "progressPercentage", "type": "int"}, + "aad_client_id": {"key": "properties.aadClientId", "type": "str"}, + "aad_tenant_id": {"key": "properties.aadTenantId", "type": "str"}, + "aad_service_principal_object_id": {"key": "properties.aadServicePrincipalObjectId", "type": "str"}, + "aad_application_object_id": {"key": "properties.aadApplicationObjectId", "type": "str"}, } def __init__( self, *, - error_code: Optional[str] = None, - error_message: Optional[str] = None, - provisioning_status: Optional["_models.GalleryImageStatusProvisioningStatus"] = None, - download_status: Optional["_models.GalleryImageStatusDownloadStatus"] = None, - progress_percentage: Optional[int] = None, + aad_client_id: Optional[str] = None, + aad_tenant_id: Optional[str] = None, + aad_service_principal_object_id: Optional[str] = None, + aad_application_object_id: Optional[str] = None, **kwargs: Any ) -> None: """ - :keyword error_code: GalleryImage provisioning error code. - :paramtype error_code: str - :keyword error_message: Descriptive error message. - :paramtype error_message: str - :keyword provisioning_status: - :paramtype provisioning_status: - ~azure.mgmt.azurestackhci.models.GalleryImageStatusProvisioningStatus - :keyword download_status: The download status of the gallery image. - :paramtype download_status: ~azure.mgmt.azurestackhci.models.GalleryImageStatusDownloadStatus - :keyword progress_percentage: The progress of the operation in percentage. - :paramtype progress_percentage: int + :keyword aad_client_id: + :paramtype aad_client_id: str + :keyword aad_tenant_id: + :paramtype aad_tenant_id: str + :keyword aad_service_principal_object_id: + :paramtype aad_service_principal_object_id: str + :keyword aad_application_object_id: + :paramtype aad_application_object_id: str """ super().__init__(**kwargs) - self.error_code = error_code - self.error_message = error_message - self.provisioning_status = provisioning_status - self.download_status = download_status - self.progress_percentage = progress_percentage + self.aad_client_id = aad_client_id + self.aad_tenant_id = aad_tenant_id + self.aad_service_principal_object_id = aad_service_principal_object_id + self.aad_application_object_id = aad_application_object_id -class GalleryImageStatusDownloadStatus(_serialization.Model): - """The download status of the gallery image. +class ClusterList(_serialization.Model): + """List of clusters. - :ivar download_size_in_mb: The downloaded sized of the image in MB. - :vartype download_size_in_mb: int + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of clusters. + :vartype value: list[~azure.mgmt.azurestackhci.models.Cluster] + :ivar next_link: Link to the next set of results. + :vartype next_link: str """ + _validation = { + "next_link": {"readonly": True}, + } + _attribute_map = { - "download_size_in_mb": {"key": "downloadSizeInMB", "type": "int"}, + "value": {"key": "value", "type": "[Cluster]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, *, download_size_in_mb: Optional[int] = None, **kwargs: Any) -> None: + def __init__(self, *, value: Optional[List["_models.Cluster"]] = None, **kwargs: Any) -> None: """ - :keyword download_size_in_mb: The downloaded sized of the image in MB. - :paramtype download_size_in_mb: int + :keyword value: List of clusters. + :paramtype value: list[~azure.mgmt.azurestackhci.models.Cluster] """ super().__init__(**kwargs) - self.download_size_in_mb = download_size_in_mb + self.value = value + self.next_link = None -class GalleryImageStatusProvisioningStatus(_serialization.Model): - """GalleryImageStatusProvisioningStatus. +class ClusterNode(_serialization.Model): # pylint: disable=too-many-instance-attributes + """Cluster node details. - :ivar operation_id: The ID of the operation performed on the gallery image. - :vartype operation_id: str - :ivar status: The status of the operation performed on the gallery image [Succeeded, Failed, - InProgress]. Known values are: "Succeeded", "Failed", and "InProgress". - :vartype status: str or ~azure.mgmt.azurestackhci.models.Status + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Name of the cluster node. + :vartype name: str + :ivar id: Id of the node in the cluster. + :vartype id: float + :ivar windows_server_subscription: State of Windows Server Subscription. Known values are: + "Disabled" and "Enabled". + :vartype windows_server_subscription: str or + ~azure.mgmt.azurestackhci.models.WindowsServerSubscription + :ivar node_type: Type of the cluster node hardware. Known values are: "FirstParty" and + "ThirdParty". + :vartype node_type: str or ~azure.mgmt.azurestackhci.models.ClusterNodeType + :ivar ehc_resource_id: Edge Hardware Center Resource Id. + :vartype ehc_resource_id: str + :ivar manufacturer: Manufacturer of the cluster node hardware. + :vartype manufacturer: str + :ivar model: Model name of the cluster node hardware. + :vartype model: str + :ivar os_name: Operating system running on the cluster node. + :vartype os_name: str + :ivar os_version: Version of the operating system running on the cluster node. + :vartype os_version: str + :ivar os_display_version: Display version of the operating system running on the cluster node. + :vartype os_display_version: str + :ivar serial_number: Immutable id of the cluster node. + :vartype serial_number: str + :ivar core_count: Number of physical cores on the cluster node. + :vartype core_count: float + :ivar memory_in_gi_b: Total available memory on the cluster node (in GiB). + :vartype memory_in_gi_b: float + :ivar last_licensing_timestamp: Most recent licensing timestamp. + :vartype last_licensing_timestamp: ~datetime.datetime + :ivar oem_activation: OEM activation status of the node. Known values are: "Disabled" and + "Enabled". + :vartype oem_activation: str or ~azure.mgmt.azurestackhci.models.OemActivation """ + _validation = { + "name": {"readonly": True}, + "id": {"readonly": True}, + "windows_server_subscription": {"readonly": True}, + "node_type": {"readonly": True}, + "ehc_resource_id": {"readonly": True}, + "manufacturer": {"readonly": True}, + "model": {"readonly": True}, + "os_name": {"readonly": True}, + "os_version": {"readonly": True}, + "os_display_version": {"readonly": True}, + "serial_number": {"readonly": True}, + "core_count": {"readonly": True}, + "memory_in_gi_b": {"readonly": True}, + "last_licensing_timestamp": {"readonly": True}, + "oem_activation": {"readonly": True}, + } + _attribute_map = { - "operation_id": {"key": "operationId", "type": "str"}, - "status": {"key": "status", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "id": {"key": "id", "type": "float"}, + "windows_server_subscription": {"key": "windowsServerSubscription", "type": "str"}, + "node_type": {"key": "nodeType", "type": "str"}, + "ehc_resource_id": {"key": "ehcResourceId", "type": "str"}, + "manufacturer": {"key": "manufacturer", "type": "str"}, + "model": {"key": "model", "type": "str"}, + "os_name": {"key": "osName", "type": "str"}, + "os_version": {"key": "osVersion", "type": "str"}, + "os_display_version": {"key": "osDisplayVersion", "type": "str"}, + "serial_number": {"key": "serialNumber", "type": "str"}, + "core_count": {"key": "coreCount", "type": "float"}, + "memory_in_gi_b": {"key": "memoryInGiB", "type": "float"}, + "last_licensing_timestamp": {"key": "lastLicensingTimestamp", "type": "iso-8601"}, + "oem_activation": {"key": "oemActivation", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.name = None + self.id = None + self.windows_server_subscription = None + self.node_type = None + self.ehc_resource_id = None + self.manufacturer = None + self.model = None + self.os_name = None + self.os_version = None + self.os_display_version = None + self.serial_number = None + self.core_count = None + self.memory_in_gi_b = None + self.last_licensing_timestamp = None + self.oem_activation = None + + +class ClusterPatch(_serialization.Model): + """Cluster details to update. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar cloud_management_endpoint: Endpoint configured for management from the Azure portal. + :vartype cloud_management_endpoint: str + :ivar aad_client_id: App id of cluster AAD identity. + :vartype aad_client_id: str + :ivar aad_tenant_id: Tenant id of cluster AAD identity. + :vartype aad_tenant_id: str + :ivar desired_properties: Desired properties of the cluster. + :vartype desired_properties: ~azure.mgmt.azurestackhci.models.ClusterDesiredProperties + :ivar principal_id: The service principal ID of the system assigned identity. This property + will only be provided for a system assigned identity. + :vartype principal_id: str + :ivar tenant_id: The tenant ID of the system assigned identity. This property will only be + provided for a system assigned identity. + :vartype tenant_id: str + :ivar type: Type of managed service identity (where both SystemAssigned and UserAssigned types + are allowed). Known values are: "None", "SystemAssigned", "UserAssigned", and "SystemAssigned, + UserAssigned". + :vartype type: str or ~azure.mgmt.azurestackhci.models.ManagedServiceIdentityType + :ivar user_assigned_identities: The set of user assigned identities associated with the + resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. # pylint: disable=line-too-long + The dictionary values can be empty objects ({}) in requests. + :vartype user_assigned_identities: dict[str, + ~azure.mgmt.azurestackhci.models.UserAssignedIdentity] + """ + + _validation = { + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, + } + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + "cloud_management_endpoint": {"key": "properties.cloudManagementEndpoint", "type": "str"}, + "aad_client_id": {"key": "properties.aadClientId", "type": "str"}, + "aad_tenant_id": {"key": "properties.aadTenantId", "type": "str"}, + "desired_properties": {"key": "properties.desiredProperties", "type": "ClusterDesiredProperties"}, + "principal_id": {"key": "identity.principalId", "type": "str"}, + "tenant_id": {"key": "identity.tenantId", "type": "str"}, + "type": {"key": "identity.type", "type": "str"}, + "user_assigned_identities": {"key": "identity.userAssignedIdentities", "type": "{UserAssignedIdentity}"}, } def __init__( self, *, - operation_id: Optional[str] = None, - status: Optional[Union[str, "_models.Status"]] = None, + tags: Optional[Dict[str, str]] = None, + cloud_management_endpoint: Optional[str] = None, + aad_client_id: Optional[str] = None, + aad_tenant_id: Optional[str] = None, + desired_properties: Optional["_models.ClusterDesiredProperties"] = None, + type: Optional[Union[str, "_models.ManagedServiceIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentity"]] = None, **kwargs: Any ) -> None: """ - :keyword operation_id: The ID of the operation performed on the gallery image. - :paramtype operation_id: str - :keyword status: The status of the operation performed on the gallery image [Succeeded, Failed, - InProgress]. Known values are: "Succeeded", "Failed", and "InProgress". - :paramtype status: str or ~azure.mgmt.azurestackhci.models.Status + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword cloud_management_endpoint: Endpoint configured for management from the Azure portal. + :paramtype cloud_management_endpoint: str + :keyword aad_client_id: App id of cluster AAD identity. + :paramtype aad_client_id: str + :keyword aad_tenant_id: Tenant id of cluster AAD identity. + :paramtype aad_tenant_id: str + :keyword desired_properties: Desired properties of the cluster. + :paramtype desired_properties: ~azure.mgmt.azurestackhci.models.ClusterDesiredProperties + :keyword type: Type of managed service identity (where both SystemAssigned and UserAssigned + types are allowed). Known values are: "None", "SystemAssigned", "UserAssigned", and + "SystemAssigned, UserAssigned". + :paramtype type: str or ~azure.mgmt.azurestackhci.models.ManagedServiceIdentityType + :keyword user_assigned_identities: The set of user assigned identities associated with the + resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. # pylint: disable=line-too-long + The dictionary values can be empty objects ({}) in requests. + :paramtype user_assigned_identities: dict[str, + ~azure.mgmt.azurestackhci.models.UserAssignedIdentity] """ super().__init__(**kwargs) - self.operation_id = operation_id - self.status = status + self.tags = tags + self.cloud_management_endpoint = cloud_management_endpoint + self.aad_client_id = aad_client_id + self.aad_tenant_id = aad_tenant_id + self.desired_properties = desired_properties + self.principal_id = None + self.tenant_id = None + self.type = type + self.user_assigned_identities = user_assigned_identities -class GalleryImagesUpdateRequest(_serialization.Model): - """The gallery images resource patch definition. +class ClusterReportedProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes + """Properties reported by cluster agent. - :ivar tags: Resource tags. - :vartype tags: dict[str, str] + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar cluster_name: Name of the on-prem cluster connected to this resource. + :vartype cluster_name: str + :ivar cluster_id: Unique id generated by the on-prem cluster. + :vartype cluster_id: str + :ivar cluster_version: Version of the cluster software. + :vartype cluster_version: str + :ivar nodes: List of nodes reported by the cluster. + :vartype nodes: list[~azure.mgmt.azurestackhci.models.ClusterNode] + :ivar last_updated: Last time the cluster reported the data. + :vartype last_updated: ~datetime.datetime + :ivar imds_attestation: IMDS attestation status of the cluster. Known values are: "Disabled" + and "Enabled". + :vartype imds_attestation: str or ~azure.mgmt.azurestackhci.models.ImdsAttestation + :ivar diagnostic_level: Level of diagnostic data emitted by the cluster. Known values are: + "Off", "Basic", and "Enhanced". + :vartype diagnostic_level: str or ~azure.mgmt.azurestackhci.models.DiagnosticLevel + :ivar supported_capabilities: Capabilities supported by the cluster. + :vartype supported_capabilities: list[str] + :ivar cluster_type: The node type of all the nodes of the cluster. Known values are: + "FirstParty" and "ThirdParty". + :vartype cluster_type: str or ~azure.mgmt.azurestackhci.models.ClusterNodeType + :ivar manufacturer: The manufacturer of all the nodes of the cluster. + :vartype manufacturer: str + :ivar oem_activation: OEM activation status of the cluster. Known values are: "Disabled" and + "Enabled". + :vartype oem_activation: str or ~azure.mgmt.azurestackhci.models.OemActivation """ + _validation = { + "cluster_name": {"readonly": True}, + "cluster_id": {"readonly": True}, + "cluster_version": {"readonly": True}, + "nodes": {"readonly": True}, + "last_updated": {"readonly": True}, + "imds_attestation": {"readonly": True}, + "supported_capabilities": {"readonly": True}, + "cluster_type": {"readonly": True}, + "manufacturer": {"readonly": True}, + "oem_activation": {"readonly": True}, + } + _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, + "cluster_name": {"key": "clusterName", "type": "str"}, + "cluster_id": {"key": "clusterId", "type": "str"}, + "cluster_version": {"key": "clusterVersion", "type": "str"}, + "nodes": {"key": "nodes", "type": "[ClusterNode]"}, + "last_updated": {"key": "lastUpdated", "type": "iso-8601"}, + "imds_attestation": {"key": "imdsAttestation", "type": "str"}, + "diagnostic_level": {"key": "diagnosticLevel", "type": "str"}, + "supported_capabilities": {"key": "supportedCapabilities", "type": "[str]"}, + "cluster_type": {"key": "clusterType", "type": "str"}, + "manufacturer": {"key": "manufacturer", "type": "str"}, + "oem_activation": {"key": "oemActivation", "type": "str"}, } - def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + def __init__( + self, *, diagnostic_level: Optional[Union[str, "_models.DiagnosticLevel"]] = None, **kwargs: Any + ) -> None: """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] + :keyword diagnostic_level: Level of diagnostic data emitted by the cluster. Known values are: + "Off", "Basic", and "Enhanced". + :paramtype diagnostic_level: str or ~azure.mgmt.azurestackhci.models.DiagnosticLevel """ super().__init__(**kwargs) - self.tags = tags + self.cluster_name = None + self.cluster_id = None + self.cluster_version = None + self.nodes = None + self.last_updated = None + self.imds_attestation = None + self.diagnostic_level = diagnostic_level + self.supported_capabilities = None + self.cluster_type = None + self.manufacturer = None + self.oem_activation = None + + +class DefaultExtensionDetails(_serialization.Model): + """Properties for a particular default extension category. + Variables are only populated by the server, and will be ignored when sending a request. -class GalleryImageVersion(_serialization.Model): - """Specifies information about the gallery image version that you want to create or update. + :ivar category: Default extension category. + :vartype category: str + :ivar consent_time: Consent time for extension category. + :vartype consent_time: ~datetime.datetime + """ - :ivar name: This is the version of the gallery image. + _validation = { + "category": {"readonly": True}, + "consent_time": {"readonly": True}, + } + + _attribute_map = { + "category": {"key": "category", "type": "str"}, + "consent_time": {"key": "consentTime", "type": "iso-8601"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.category = None + self.consent_time = None + + +class DeploymentCluster(_serialization.Model): + """AzureStackHCI Cluster deployment properties. + + :ivar name: The cluster name provided when preparing Active Directory. :vartype name: str - :ivar storage_profile: This is the storage profile of a Gallery Image Version. - :vartype storage_profile: ~azure.mgmt.azurestackhci.models.GalleryImageVersionStorageProfile + :ivar witness_type: Use a cloud witness if you have internet access and if you use an Azure + Storage account to provide a vote on cluster quorum. A cloud witness uses Azure Blob Storage to + read or write a blob file and then uses it to arbitrate in split-brain resolution. Only allowed + values are 'Cloud', 'FileShare'. + :vartype witness_type: str + :ivar witness_path: Specify the fileshare path for the local witness for your Azure Stack HCI + cluster. + :vartype witness_path: str + :ivar cloud_account_name: Specify the Azure Storage account name for cloud witness for your + Azure Stack HCI cluster. + :vartype cloud_account_name: str + :ivar azure_service_endpoint: For Azure blob service endpoint type, select either Default or + Custom domain. If you selected **Custom domain, enter the domain for the blob service in this + format core.windows.net. + :vartype azure_service_endpoint: str """ _attribute_map = { "name": {"key": "name", "type": "str"}, - "storage_profile": {"key": "properties.storageProfile", "type": "GalleryImageVersionStorageProfile"}, + "witness_type": {"key": "witnessType", "type": "str"}, + "witness_path": {"key": "witnessPath", "type": "str"}, + "cloud_account_name": {"key": "cloudAccountName", "type": "str"}, + "azure_service_endpoint": {"key": "azureServiceEndpoint", "type": "str"}, } def __init__( self, *, name: Optional[str] = None, - storage_profile: Optional["_models.GalleryImageVersionStorageProfile"] = None, + witness_type: Optional[str] = None, + witness_path: Optional[str] = None, + cloud_account_name: Optional[str] = None, + azure_service_endpoint: Optional[str] = None, **kwargs: Any ) -> None: """ - :keyword name: This is the version of the gallery image. + :keyword name: The cluster name provided when preparing Active Directory. :paramtype name: str - :keyword storage_profile: This is the storage profile of a Gallery Image Version. - :paramtype storage_profile: ~azure.mgmt.azurestackhci.models.GalleryImageVersionStorageProfile + :keyword witness_type: Use a cloud witness if you have internet access and if you use an Azure + Storage account to provide a vote on cluster quorum. A cloud witness uses Azure Blob Storage to + read or write a blob file and then uses it to arbitrate in split-brain resolution. Only allowed + values are 'Cloud', 'FileShare'. + :paramtype witness_type: str + :keyword witness_path: Specify the fileshare path for the local witness for your Azure Stack + HCI cluster. + :paramtype witness_path: str + :keyword cloud_account_name: Specify the Azure Storage account name for cloud witness for your + Azure Stack HCI cluster. + :paramtype cloud_account_name: str + :keyword azure_service_endpoint: For Azure blob service endpoint type, select either Default or + Custom domain. If you selected **Custom domain, enter the domain for the blob service in this + format core.windows.net. + :paramtype azure_service_endpoint: str """ super().__init__(**kwargs) self.name = name - self.storage_profile = storage_profile + self.witness_type = witness_type + self.witness_path = witness_path + self.cloud_account_name = cloud_account_name + self.azure_service_endpoint = azure_service_endpoint -class GalleryImageVersionStorageProfile(_serialization.Model): - """This is the storage profile of a Gallery Image Version. +class DeploymentConfiguration(_serialization.Model): + """Deployment Configuration. - :ivar os_disk_image: This is the OS disk image. - :vartype os_disk_image: ~azure.mgmt.azurestackhci.models.GalleryOSDiskImage + All required parameters must be populated in order to send to server. + + :ivar version: deployment template version. + :vartype version: str + :ivar scale_units: Scale units will contains list of deployment data. Required. + :vartype scale_units: list[~azure.mgmt.azurestackhci.models.ScaleUnits] """ + _validation = { + "scale_units": {"required": True}, + } + _attribute_map = { - "os_disk_image": {"key": "osDiskImage", "type": "GalleryOSDiskImage"}, + "version": {"key": "version", "type": "str"}, + "scale_units": {"key": "scaleUnits", "type": "[ScaleUnits]"}, } - def __init__(self, *, os_disk_image: Optional["_models.GalleryOSDiskImage"] = None, **kwargs: Any) -> None: + def __init__( + self, *, scale_units: List["_models.ScaleUnits"], version: Optional[str] = None, **kwargs: Any + ) -> None: """ - :keyword os_disk_image: This is the OS disk image. - :paramtype os_disk_image: ~azure.mgmt.azurestackhci.models.GalleryOSDiskImage + :keyword version: deployment template version. + :paramtype version: str + :keyword scale_units: Scale units will contains list of deployment data. Required. + :paramtype scale_units: list[~azure.mgmt.azurestackhci.models.ScaleUnits] """ super().__init__(**kwargs) - self.os_disk_image = os_disk_image - - -class GalleryOSDiskImage(GalleryDiskImage): - """This is the OS disk image. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar size_in_mb: This property indicates the size of the VHD to be created. - :vartype size_in_mb: int + self.version = version + self.scale_units = scale_units + + +class DeploymentData(_serialization.Model): # pylint: disable=too-many-instance-attributes + """The Deployment data of AzureStackHCI Cluster. + + :ivar security_settings: SecuritySettings to deploy AzureStackHCI Cluster. + :vartype security_settings: ~azure.mgmt.azurestackhci.models.DeploymentSecuritySettings + :ivar observability: Observability config to deploy AzureStackHCI Cluster. + :vartype observability: ~azure.mgmt.azurestackhci.models.Observability + :ivar cluster: Observability config to deploy AzureStackHCI Cluster. + :vartype cluster: ~azure.mgmt.azurestackhci.models.DeploymentCluster + :ivar storage: Storage config to deploy AzureStackHCI Cluster. + :vartype storage: ~azure.mgmt.azurestackhci.models.Storage + :ivar naming_prefix: naming prefix to deploy cluster. + :vartype naming_prefix: str + :ivar domain_fqdn: FQDN to deploy cluster. + :vartype domain_fqdn: str + :ivar infrastructure_network: InfrastructureNetwork config to deploy AzureStackHCI Cluster. + :vartype infrastructure_network: list[~azure.mgmt.azurestackhci.models.InfrastructureNetwork] + :ivar physical_nodes: list of physical nodes config to deploy AzureStackHCI Cluster. + :vartype physical_nodes: list[~azure.mgmt.azurestackhci.models.PhysicalNodes] + :ivar host_network: HostNetwork config to deploy AzureStackHCI Cluster. + :vartype host_network: ~azure.mgmt.azurestackhci.models.HostNetwork + :ivar adou_path: The path to the Active Directory Organizational Unit container object prepared + for the deployment. + :vartype adou_path: str + :ivar secrets_location: The URI to the keyvault / secret store. + :vartype secrets_location: str + :ivar optional_services: OptionalServices config to deploy AzureStackHCI Cluster. + :vartype optional_services: ~azure.mgmt.azurestackhci.models.OptionalServices """ _validation = { - "size_in_mb": {"readonly": True}, + "naming_prefix": {"pattern": r"^[a-zA-Z0-9-]{1,8}$"}, } _attribute_map = { - "size_in_mb": {"key": "sizeInMB", "type": "int"}, + "security_settings": {"key": "securitySettings", "type": "DeploymentSecuritySettings"}, + "observability": {"key": "observability", "type": "Observability"}, + "cluster": {"key": "cluster", "type": "DeploymentCluster"}, + "storage": {"key": "storage", "type": "Storage"}, + "naming_prefix": {"key": "namingPrefix", "type": "str"}, + "domain_fqdn": {"key": "domainFqdn", "type": "str"}, + "infrastructure_network": {"key": "infrastructureNetwork", "type": "[InfrastructureNetwork]"}, + "physical_nodes": {"key": "physicalNodes", "type": "[PhysicalNodes]"}, + "host_network": {"key": "hostNetwork", "type": "HostNetwork"}, + "adou_path": {"key": "adouPath", "type": "str"}, + "secrets_location": {"key": "secretsLocation", "type": "str"}, + "optional_services": {"key": "optionalServices", "type": "OptionalServices"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__( + self, + *, + security_settings: Optional["_models.DeploymentSecuritySettings"] = None, + observability: Optional["_models.Observability"] = None, + cluster: Optional["_models.DeploymentCluster"] = None, + storage: Optional["_models.Storage"] = None, + naming_prefix: Optional[str] = None, + domain_fqdn: Optional[str] = None, + infrastructure_network: Optional[List["_models.InfrastructureNetwork"]] = None, + physical_nodes: Optional[List["_models.PhysicalNodes"]] = None, + host_network: Optional["_models.HostNetwork"] = None, + adou_path: Optional[str] = None, + secrets_location: Optional[str] = None, + optional_services: Optional["_models.OptionalServices"] = None, + **kwargs: Any + ) -> None: + """ + :keyword security_settings: SecuritySettings to deploy AzureStackHCI Cluster. + :paramtype security_settings: ~azure.mgmt.azurestackhci.models.DeploymentSecuritySettings + :keyword observability: Observability config to deploy AzureStackHCI Cluster. + :paramtype observability: ~azure.mgmt.azurestackhci.models.Observability + :keyword cluster: Observability config to deploy AzureStackHCI Cluster. + :paramtype cluster: ~azure.mgmt.azurestackhci.models.DeploymentCluster + :keyword storage: Storage config to deploy AzureStackHCI Cluster. + :paramtype storage: ~azure.mgmt.azurestackhci.models.Storage + :keyword naming_prefix: naming prefix to deploy cluster. + :paramtype naming_prefix: str + :keyword domain_fqdn: FQDN to deploy cluster. + :paramtype domain_fqdn: str + :keyword infrastructure_network: InfrastructureNetwork config to deploy AzureStackHCI Cluster. + :paramtype infrastructure_network: list[~azure.mgmt.azurestackhci.models.InfrastructureNetwork] + :keyword physical_nodes: list of physical nodes config to deploy AzureStackHCI Cluster. + :paramtype physical_nodes: list[~azure.mgmt.azurestackhci.models.PhysicalNodes] + :keyword host_network: HostNetwork config to deploy AzureStackHCI Cluster. + :paramtype host_network: ~azure.mgmt.azurestackhci.models.HostNetwork + :keyword adou_path: The path to the Active Directory Organizational Unit container object + prepared for the deployment. + :paramtype adou_path: str + :keyword secrets_location: The URI to the keyvault / secret store. + :paramtype secrets_location: str + :keyword optional_services: OptionalServices config to deploy AzureStackHCI Cluster. + :paramtype optional_services: ~azure.mgmt.azurestackhci.models.OptionalServices + """ super().__init__(**kwargs) + self.security_settings = security_settings + self.observability = observability + self.cluster = cluster + self.storage = storage + self.naming_prefix = naming_prefix + self.domain_fqdn = domain_fqdn + self.infrastructure_network = infrastructure_network + self.physical_nodes = physical_nodes + self.host_network = host_network + self.adou_path = adou_path + self.secrets_location = secrets_location + self.optional_services = optional_services + + +class DeploymentSecuritySettings(_serialization.Model): + """The SecuritySettings of AzureStackHCI Cluster. + + :ivar hvci_protection: By default, Hypervisor-protected Code Integrity is enabled on your Azure + HCI cluster. + :vartype hvci_protection: bool + :ivar drtm_protection: By default, Secure Boot is enabled on your Azure HCI cluster. This + setting is hardware dependent. + :vartype drtm_protection: bool + :ivar drift_control_enforced: When set to true, the security baseline is re-applied regularly. + :vartype drift_control_enforced: bool + :ivar credential_guard_enforced: When set to true, Credential Guard is enabled. + :vartype credential_guard_enforced: bool + :ivar smb_signing_enforced: When set to true, the SMB default instance requires sign in for the + client and server services. + :vartype smb_signing_enforced: bool + :ivar smb_cluster_encryption: When set to true, cluster east-west traffic is encrypted. + :vartype smb_cluster_encryption: bool + :ivar side_channel_mitigation_enforced: When set to true, all the side channel mitigations are + enabled. + :vartype side_channel_mitigation_enforced: bool + :ivar bitlocker_boot_volume: When set to true, BitLocker XTS_AES 256-bit encryption is enabled + for all data-at-rest on the OS volume of your Azure Stack HCI cluster. This setting is + TPM-hardware dependent. + :vartype bitlocker_boot_volume: bool + :ivar bitlocker_data_volumes: When set to true, BitLocker XTS-AES 256-bit encryption is enabled + for all data-at-rest on your Azure Stack HCI cluster shared volumes. + :vartype bitlocker_data_volumes: bool + :ivar wdac_enforced: WDAC is enabled by default and limits the applications and the code that + you can run on your Azure Stack HCI cluster. + :vartype wdac_enforced: bool + """ + _attribute_map = { + "hvci_protection": {"key": "hvciProtection", "type": "bool"}, + "drtm_protection": {"key": "drtmProtection", "type": "bool"}, + "drift_control_enforced": {"key": "driftControlEnforced", "type": "bool"}, + "credential_guard_enforced": {"key": "credentialGuardEnforced", "type": "bool"}, + "smb_signing_enforced": {"key": "smbSigningEnforced", "type": "bool"}, + "smb_cluster_encryption": {"key": "smbClusterEncryption", "type": "bool"}, + "side_channel_mitigation_enforced": {"key": "sideChannelMitigationEnforced", "type": "bool"}, + "bitlocker_boot_volume": {"key": "bitlockerBootVolume", "type": "bool"}, + "bitlocker_data_volumes": {"key": "bitlockerDataVolumes", "type": "bool"}, + "wdac_enforced": {"key": "wdacEnforced", "type": "bool"}, + } + + def __init__( + self, + *, + hvci_protection: bool = True, + drtm_protection: bool = True, + drift_control_enforced: bool = True, + credential_guard_enforced: bool = False, + smb_signing_enforced: bool = True, + smb_cluster_encryption: bool = False, + side_channel_mitigation_enforced: bool = True, + bitlocker_boot_volume: bool = True, + bitlocker_data_volumes: bool = True, + wdac_enforced: bool = True, + **kwargs: Any + ) -> None: + """ + :keyword hvci_protection: By default, Hypervisor-protected Code Integrity is enabled on your + Azure HCI cluster. + :paramtype hvci_protection: bool + :keyword drtm_protection: By default, Secure Boot is enabled on your Azure HCI cluster. This + setting is hardware dependent. + :paramtype drtm_protection: bool + :keyword drift_control_enforced: When set to true, the security baseline is re-applied + regularly. + :paramtype drift_control_enforced: bool + :keyword credential_guard_enforced: When set to true, Credential Guard is enabled. + :paramtype credential_guard_enforced: bool + :keyword smb_signing_enforced: When set to true, the SMB default instance requires sign in for + the client and server services. + :paramtype smb_signing_enforced: bool + :keyword smb_cluster_encryption: When set to true, cluster east-west traffic is encrypted. + :paramtype smb_cluster_encryption: bool + :keyword side_channel_mitigation_enforced: When set to true, all the side channel mitigations + are enabled. + :paramtype side_channel_mitigation_enforced: bool + :keyword bitlocker_boot_volume: When set to true, BitLocker XTS_AES 256-bit encryption is + enabled for all data-at-rest on the OS volume of your Azure Stack HCI cluster. This setting is + TPM-hardware dependent. + :paramtype bitlocker_boot_volume: bool + :keyword bitlocker_data_volumes: When set to true, BitLocker XTS-AES 256-bit encryption is + enabled for all data-at-rest on your Azure Stack HCI cluster shared volumes. + :paramtype bitlocker_data_volumes: bool + :keyword wdac_enforced: WDAC is enabled by default and limits the applications and the code + that you can run on your Azure Stack HCI cluster. + :paramtype wdac_enforced: bool + """ + super().__init__(**kwargs) + self.hvci_protection = hvci_protection + self.drtm_protection = drtm_protection + self.drift_control_enforced = drift_control_enforced + self.credential_guard_enforced = credential_guard_enforced + self.smb_signing_enforced = smb_signing_enforced + self.smb_cluster_encryption = smb_cluster_encryption + self.side_channel_mitigation_enforced = side_channel_mitigation_enforced + self.bitlocker_boot_volume = bitlocker_boot_volume + self.bitlocker_data_volumes = bitlocker_data_volumes + self.wdac_enforced = wdac_enforced -class ProxyResource(Resource): - """The resource model definition for a Azure Resource Manager proxy resource. It will not have - tags and a location. + +class DeploymentSetting(ProxyResource): + """Edge device resource. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -688,6 +1411,20 @@ class ProxyResource(Resource): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.azurestackhci.models.SystemData + :ivar provisioning_state: DeploymentSetting provisioning state. Known values are: + "NotSpecified", "Error", "Succeeded", "Failed", "Canceled", "Connected", "Disconnected", + "Deleted", "Creating", "Updating", "Deleting", "Moving", "PartiallySucceeded", + "PartiallyConnected", "InProgress", "Accepted", "Provisioning", and "DisableInProgress". + :vartype provisioning_state: str or ~azure.mgmt.azurestackhci.models.ProvisioningState + :ivar arc_node_resource_ids: Azure resource ids of Arc machines to be part of cluster. + :vartype arc_node_resource_ids: list[str] + :ivar deployment_mode: The deployment mode for cluster deployment. Known values are: "Validate" + and "Deploy". + :vartype deployment_mode: str or ~azure.mgmt.azurestackhci.models.DeploymentMode + :ivar deployment_configuration: Scale units will contains list of deployment data. + :vartype deployment_configuration: ~azure.mgmt.azurestackhci.models.DeploymentConfiguration + :ivar reported_properties: Deployment Status reported from cluster. + :vartype reported_properties: ~azure.mgmt.azurestackhci.models.ReportedProperties """ _validation = { @@ -695,6 +1432,7 @@ class ProxyResource(Resource): "name": {"readonly": True}, "type": {"readonly": True}, "system_data": {"readonly": True}, + "reported_properties": {"readonly": True}, } _attribute_map = { @@ -702,285 +1440,421 @@ class ProxyResource(Resource): "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "arc_node_resource_ids": {"key": "properties.arcNodeResourceIds", "type": "[str]"}, + "deployment_mode": {"key": "properties.deploymentMode", "type": "str"}, + "deployment_configuration": {"key": "properties.deploymentConfiguration", "type": "DeploymentConfiguration"}, + "reported_properties": {"key": "properties.reportedProperties", "type": "ReportedProperties"}, } - def __init__(self, **kwargs: Any) -> None: - """ """ + def __init__( + self, + *, + provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None, + arc_node_resource_ids: Optional[List[str]] = None, + deployment_mode: Union[str, "_models.DeploymentMode"] = "Deploy", + deployment_configuration: Optional["_models.DeploymentConfiguration"] = None, + **kwargs: Any + ) -> None: + """ + :keyword provisioning_state: DeploymentSetting provisioning state. Known values are: + "NotSpecified", "Error", "Succeeded", "Failed", "Canceled", "Connected", "Disconnected", + "Deleted", "Creating", "Updating", "Deleting", "Moving", "PartiallySucceeded", + "PartiallyConnected", "InProgress", "Accepted", "Provisioning", and "DisableInProgress". + :paramtype provisioning_state: str or ~azure.mgmt.azurestackhci.models.ProvisioningState + :keyword arc_node_resource_ids: Azure resource ids of Arc machines to be part of cluster. + :paramtype arc_node_resource_ids: list[str] + :keyword deployment_mode: The deployment mode for cluster deployment. Known values are: + "Validate" and "Deploy". + :paramtype deployment_mode: str or ~azure.mgmt.azurestackhci.models.DeploymentMode + :keyword deployment_configuration: Scale units will contains list of deployment data. + :paramtype deployment_configuration: ~azure.mgmt.azurestackhci.models.DeploymentConfiguration + """ super().__init__(**kwargs) + self.provisioning_state = provisioning_state + self.arc_node_resource_ids = arc_node_resource_ids + self.deployment_mode = deployment_mode + self.deployment_configuration = deployment_configuration + self.reported_properties = None -class GuestAgent(ProxyResource): - """Defines the GuestAgent. +class DeploymentSettingListResult(_serialization.Model): + """The response of a DeploymentSetting list operation. - Variables are only populated by the server, and will be ignored when sending a request. + All required parameters must be populated in order to send to server. - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.azurestackhci.models.SystemData - :ivar credentials: Username / Password Credentials to provision guest agent. - :vartype credentials: ~azure.mgmt.azurestackhci.models.GuestCredential - :ivar provisioning_action: The guest agent provisioning action. Known values are: "install", - "uninstall", and "repair". - :vartype provisioning_action: str or ~azure.mgmt.azurestackhci.models.ProvisioningAction - :ivar status: The guest agent status. - :vartype status: str - :ivar provisioning_state: The provisioning state. - :vartype provisioning_state: str + :ivar value: The DeploymentSetting items on this page. Required. + :vartype value: list[~azure.mgmt.azurestackhci.models.DeploymentSetting] + :ivar next_link: The link to the next page of items. + :vartype next_link: str """ _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "status": {"readonly": True}, - "provisioning_state": {"readonly": True}, + "value": {"required": True}, } _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "system_data": {"key": "systemData", "type": "SystemData"}, - "credentials": {"key": "properties.credentials", "type": "GuestCredential"}, - "provisioning_action": {"key": "properties.provisioningAction", "type": "str"}, - "status": {"key": "properties.status", "type": "str"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "value": {"key": "value", "type": "[DeploymentSetting]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - credentials: Optional["_models.GuestCredential"] = None, - provisioning_action: Optional[Union[str, "_models.ProvisioningAction"]] = None, - **kwargs: Any + self, *, value: List["_models.DeploymentSetting"], next_link: Optional[str] = None, **kwargs: Any ) -> None: """ - :keyword credentials: Username / Password Credentials to provision guest agent. - :paramtype credentials: ~azure.mgmt.azurestackhci.models.GuestCredential - :keyword provisioning_action: The guest agent provisioning action. Known values are: "install", - "uninstall", and "repair". - :paramtype provisioning_action: str or ~azure.mgmt.azurestackhci.models.ProvisioningAction + :keyword value: The DeploymentSetting items on this page. Required. + :paramtype value: list[~azure.mgmt.azurestackhci.models.DeploymentSetting] + :keyword next_link: The link to the next page of items. + :paramtype next_link: str """ super().__init__(**kwargs) - self.credentials = credentials - self.provisioning_action = provisioning_action - self.status = None - self.provisioning_state = None + self.value = value + self.next_link = next_link -class GuestAgentInstallStatus(_serialization.Model): - """Defines the status of a guest agent installation. +class DeploymentStatus(_serialization.Model): + """The DeploymentStatus of AzureStackHCI Cluster. Variables are only populated by the server, and will be ignored when sending a request. - :ivar vm_uuid: Specifies the VM's unique SMBIOS ID. - :vartype vm_uuid: str - :ivar status: The installation status of the hybrid machine agent installation. Known values - are: "Succeeded", "InProgress", and "Failed". - :vartype status: str or ~azure.mgmt.azurestackhci.models.StatusTypes - :ivar last_status_change: The time of the last status change. - :vartype last_status_change: ~datetime.datetime - :ivar agent_version: The hybrid machine agent full version. - :vartype agent_version: str - :ivar error_details: Details about the error state. - :vartype error_details: list[~azure.mgmt.azurestackhci.models.ErrorDetail] + :ivar status: Status of AzureStackHCI Cluster Deployment. + :vartype status: str + :ivar steps: List of steps of AzureStackHCI Cluster Deployment. + :vartype steps: list[~azure.mgmt.azurestackhci.models.DeploymentStep] """ _validation = { - "vm_uuid": {"readonly": True}, "status": {"readonly": True}, - "last_status_change": {"readonly": True}, - "agent_version": {"readonly": True}, - "error_details": {"readonly": True}, + "steps": {"readonly": True}, } _attribute_map = { - "vm_uuid": {"key": "vmUuid", "type": "str"}, "status": {"key": "status", "type": "str"}, - "last_status_change": {"key": "lastStatusChange", "type": "iso-8601"}, - "agent_version": {"key": "agentVersion", "type": "str"}, - "error_details": {"key": "errorDetails", "type": "[ErrorDetail]"}, + "steps": {"key": "steps", "type": "[DeploymentStep]"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.vm_uuid = None self.status = None - self.last_status_change = None - self.agent_version = None - self.error_details = None + self.steps = None -class GuestAgentList(_serialization.Model): - """List of GuestAgent. +class DeploymentStep(_serialization.Model): + """The Step of AzureStackHCI Cluster. - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar next_link: Url to follow for getting next page of GuestAgent. - :vartype next_link: str - :ivar value: Array of GuestAgent. Required. - :vartype value: list[~azure.mgmt.azurestackhci.models.GuestAgent] + :ivar name: Name of step. + :vartype name: str + :ivar description: Description of step. + :vartype description: str + :ivar full_step_index: FullStepIndex of step. + :vartype full_step_index: str + :ivar start_time_utc: Start time of step. + :vartype start_time_utc: str + :ivar end_time_utc: End time of step. + :vartype end_time_utc: str + :ivar status: Status of step. Allowed values are 'Error', 'Success', 'InProgress'. + :vartype status: str + :ivar steps: List of nested steps of AzureStackHCI Cluster Deployment. + :vartype steps: list[~azure.mgmt.azurestackhci.models.DeploymentStep] + :ivar exception: List of exceptions in AzureStackHCI Cluster Deployment. + :vartype exception: list[str] """ _validation = { - "value": {"required": True}, + "name": {"readonly": True}, + "description": {"readonly": True}, + "full_step_index": {"readonly": True}, + "start_time_utc": {"readonly": True}, + "end_time_utc": {"readonly": True}, + "status": {"readonly": True}, + "steps": {"readonly": True}, + "exception": {"readonly": True}, } _attribute_map = { - "next_link": {"key": "nextLink", "type": "str"}, - "value": {"key": "value", "type": "[GuestAgent]"}, + "name": {"key": "name", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "full_step_index": {"key": "fullStepIndex", "type": "str"}, + "start_time_utc": {"key": "startTimeUtc", "type": "str"}, + "end_time_utc": {"key": "endTimeUtc", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "steps": {"key": "steps", "type": "[DeploymentStep]"}, + "exception": {"key": "exception", "type": "[str]"}, } - def __init__(self, *, value: List["_models.GuestAgent"], next_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword next_link: Url to follow for getting next page of GuestAgent. - :paramtype next_link: str - :keyword value: Array of GuestAgent. Required. - :paramtype value: list[~azure.mgmt.azurestackhci.models.GuestAgent] - """ + def __init__(self, **kwargs: Any) -> None: + """ """ super().__init__(**kwargs) - self.next_link = next_link - self.value = value + self.name = None + self.description = None + self.full_step_index = None + self.start_time_utc = None + self.end_time_utc = None + self.status = None + self.steps = None + self.exception = None -class GuestCredential(_serialization.Model): - """Username / Password Credentials to connect to guest. +class DeviceConfiguration(_serialization.Model): + """The device Configuration of a device. - :ivar username: The username to connect with the guest. - :vartype username: str - :ivar password: The password to connect with the guest. - :vartype password: str + :ivar nic_details: NIC Details of device. + :vartype nic_details: list[~azure.mgmt.azurestackhci.models.NicDetail] + :ivar device_metadata: device metadata details. + :vartype device_metadata: str """ _attribute_map = { - "username": {"key": "username", "type": "str"}, - "password": {"key": "password", "type": "str"}, + "nic_details": {"key": "nicDetails", "type": "[NicDetail]"}, + "device_metadata": {"key": "deviceMetadata", "type": "str"}, } - def __init__(self, *, username: Optional[str] = None, password: Optional[str] = None, **kwargs: Any) -> None: + def __init__( + self, + *, + nic_details: Optional[List["_models.NicDetail"]] = None, + device_metadata: Optional[str] = None, + **kwargs: Any + ) -> None: """ - :keyword username: The username to connect with the guest. - :paramtype username: str - :keyword password: The password to connect with the guest. - :paramtype password: str + :keyword nic_details: NIC Details of device. + :paramtype nic_details: list[~azure.mgmt.azurestackhci.models.NicDetail] + :keyword device_metadata: device metadata details. + :paramtype device_metadata: str """ super().__init__(**kwargs) - self.username = username - self.password = password + self.nic_details = nic_details + self.device_metadata = device_metadata -class HardwareProfileUpdate(_serialization.Model): - """HardwareProfile - Specifies the hardware settings for the virtual machine instance. +class EdgeDevice(ProxyResource): + """Edge device resource. - :ivar vm_size: Known values are: "Default", "Standard_A2_v2", "Standard_A4_v2", - "Standard_D2s_v3", "Standard_D4s_v3", "Standard_D8s_v3", "Standard_D16s_v3", - "Standard_D32s_v3", "Standard_DS2_v2", "Standard_DS3_v2", "Standard_DS4_v2", "Standard_DS5_v2", - "Standard_DS13_v2", "Standard_K8S_v1", "Standard_K8S2_v1", "Standard_K8S3_v1", - "Standard_K8S4_v1", "Standard_NK6", "Standard_NK12", "Standard_NV6", "Standard_NV12", - "Standard_K8S5_v1", and "Custom". - :vartype vm_size: str or ~azure.mgmt.azurestackhci.models.VmSizeEnum - :ivar processors: number of processors for the virtual machine instance. - :vartype processors: int - :ivar memory_mb: RAM in MB for the virtual machine instance. - :vartype memory_mb: int + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.azurestackhci.models.SystemData + :ivar device_configuration: Device Configuration. + :vartype device_configuration: ~azure.mgmt.azurestackhci.models.DeviceConfiguration + :ivar provisioning_state: Provisioning state of edgeDevice resource. Known values are: + "NotSpecified", "Error", "Succeeded", "Failed", "Canceled", "Connected", "Disconnected", + "Deleted", "Creating", "Updating", "Deleting", "Moving", "PartiallySucceeded", + "PartiallyConnected", "InProgress", "Accepted", "Provisioning", and "DisableInProgress". + :vartype provisioning_state: str or ~azure.mgmt.azurestackhci.models.ProvisioningState """ + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + } + _attribute_map = { - "vm_size": {"key": "vmSize", "type": "str"}, - "processors": {"key": "processors", "type": "int"}, - "memory_mb": {"key": "memoryMB", "type": "int"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "device_configuration": {"key": "properties.deviceConfiguration", "type": "DeviceConfiguration"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( self, *, - vm_size: Optional[Union[str, "_models.VmSizeEnum"]] = None, - processors: Optional[int] = None, - memory_mb: Optional[int] = None, + device_configuration: Optional["_models.DeviceConfiguration"] = None, + provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None, **kwargs: Any ) -> None: """ - :keyword vm_size: Known values are: "Default", "Standard_A2_v2", "Standard_A4_v2", - "Standard_D2s_v3", "Standard_D4s_v3", "Standard_D8s_v3", "Standard_D16s_v3", - "Standard_D32s_v3", "Standard_DS2_v2", "Standard_DS3_v2", "Standard_DS4_v2", "Standard_DS5_v2", - "Standard_DS13_v2", "Standard_K8S_v1", "Standard_K8S2_v1", "Standard_K8S3_v1", - "Standard_K8S4_v1", "Standard_NK6", "Standard_NK12", "Standard_NV6", "Standard_NV12", - "Standard_K8S5_v1", and "Custom". - :paramtype vm_size: str or ~azure.mgmt.azurestackhci.models.VmSizeEnum - :keyword processors: number of processors for the virtual machine instance. - :paramtype processors: int - :keyword memory_mb: RAM in MB for the virtual machine instance. - :paramtype memory_mb: int + :keyword device_configuration: Device Configuration. + :paramtype device_configuration: ~azure.mgmt.azurestackhci.models.DeviceConfiguration + :keyword provisioning_state: Provisioning state of edgeDevice resource. Known values are: + "NotSpecified", "Error", "Succeeded", "Failed", "Canceled", "Connected", "Disconnected", + "Deleted", "Creating", "Updating", "Deleting", "Moving", "PartiallySucceeded", + "PartiallyConnected", "InProgress", "Accepted", "Provisioning", and "DisableInProgress". + :paramtype provisioning_state: str or ~azure.mgmt.azurestackhci.models.ProvisioningState """ super().__init__(**kwargs) - self.vm_size = vm_size - self.processors = processors - self.memory_mb = memory_mb + self.device_configuration = device_configuration + self.provisioning_state = provisioning_state -class HttpProxyConfiguration(_serialization.Model): - """HTTP Proxy configuration for the VM. +class EdgeDeviceListResult(_serialization.Model): + """The response of a EdgeDevice list operation. - :ivar http_proxy: The HTTP proxy server endpoint to use. - :vartype http_proxy: str - :ivar https_proxy: The HTTPS proxy server endpoint to use. - :vartype https_proxy: str - :ivar no_proxy: The endpoints that should not go through proxy. - :vartype no_proxy: list[str] - :ivar trusted_ca: Alternative CA cert to use for connecting to proxy servers. - :vartype trusted_ca: str - """ + All required parameters must be populated in order to send to server. + + :ivar value: The EdgeDevice items on this page. Required. + :vartype value: list[~azure.mgmt.azurestackhci.models.EdgeDevice] + :ivar next_link: The link to the next page of items. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } _attribute_map = { - "http_proxy": {"key": "httpProxy", "type": "str"}, - "https_proxy": {"key": "httpsProxy", "type": "str"}, - "no_proxy": {"key": "noProxy", "type": "[str]"}, - "trusted_ca": {"key": "trustedCa", "type": "str"}, + "value": {"key": "value", "type": "[EdgeDevice]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: List["_models.EdgeDevice"], next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword value: The EdgeDevice items on this page. Required. + :paramtype value: list[~azure.mgmt.azurestackhci.models.EdgeDevice] + :keyword next_link: The link to the next page of items. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ErrorAdditionalInfo(_serialization.Model): + """The resource management error additional info. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The additional info type. + :vartype type: str + :ivar info: The additional info. + :vartype info: JSON + """ + + _validation = { + "type": {"readonly": True}, + "info": {"readonly": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.type = None + self.info = None + + +class ErrorDetail(_serialization.Model): + """The error detail. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The error target. + :vartype target: str + :ivar details: The error details. + :vartype details: list[~azure.mgmt.azurestackhci.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~azure.mgmt.azurestackhci.models.ErrorAdditionalInfo] + """ + + _validation = { + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorDetail]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None + + +class ErrorResponse(_serialization.Model): + """Common error response for all Azure Resource Manager APIs to return error details for failed + operations. (This also follows the OData error response format.). + + :ivar error: The error object. + :vartype error: ~azure.mgmt.azurestackhci.models.ErrorDetail + """ + + _attribute_map = { + "error": {"key": "error", "type": "ErrorDetail"}, + } + + def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.azurestackhci.models.ErrorDetail + """ + super().__init__(**kwargs) + self.error = error + + +class ExtendedLocation(_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. "CustomLocation" + :vartype type: str or ~azure.mgmt.azurestackhci.models.ExtendedLocationTypes + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } def __init__( self, *, - http_proxy: Optional[str] = None, - https_proxy: Optional[str] = None, - no_proxy: Optional[List[str]] = None, - trusted_ca: Optional[str] = None, + name: Optional[str] = None, + type: Optional[Union[str, "_models.ExtendedLocationTypes"]] = None, **kwargs: Any ) -> None: """ - :keyword http_proxy: The HTTP proxy server endpoint to use. - :paramtype http_proxy: str - :keyword https_proxy: The HTTPS proxy server endpoint to use. - :paramtype https_proxy: str - :keyword no_proxy: The endpoints that should not go through proxy. - :paramtype no_proxy: list[str] - :keyword trusted_ca: Alternative CA cert to use for connecting to proxy servers. - :paramtype trusted_ca: str + :keyword name: The name of the extended location. + :paramtype name: str + :keyword type: The type of the extended location. "CustomLocation" + :paramtype type: str or ~azure.mgmt.azurestackhci.models.ExtendedLocationTypes """ super().__init__(**kwargs) - self.http_proxy = http_proxy - self.https_proxy = https_proxy - self.no_proxy = no_proxy - self.trusted_ca = trusted_ca + self.name = name + self.type = type -class HybridIdentityMetadata(ProxyResource): - """Defines the HybridIdentityMetadata. +class Extension(ProxyResource): # pylint: disable=too-many-instance-attributes + """Details of a particular extension in HCI Cluster. Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -990,14 +1864,45 @@ class HybridIdentityMetadata(ProxyResource): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.azurestackhci.models.SystemData - :ivar resource_uid: The unique identifier for the resource. - :vartype resource_uid: str - :ivar public_key: The Public Key. - :vartype public_key: str - :ivar identity: Identity for the resource. - :vartype identity: ~azure.mgmt.azurestackhci.models.Identity - :ivar provisioning_state: The provisioning state. - :vartype provisioning_state: str + :ivar provisioning_state: Provisioning state of the Extension proxy resource. Known values are: + "NotSpecified", "Error", "Succeeded", "Failed", "Canceled", "Connected", "Disconnected", + "Deleted", "Creating", "Updating", "Deleting", "Moving", "PartiallySucceeded", + "PartiallyConnected", "InProgress", "Accepted", "Provisioning", and "DisableInProgress". + :vartype provisioning_state: str or ~azure.mgmt.azurestackhci.models.ProvisioningState + :ivar aggregate_state: Aggregate state of Arc Extensions across the nodes in this HCI cluster. + Known values are: "NotSpecified", "Error", "Succeeded", "Canceled", "Failed", "Connected", + "Disconnected", "Deleted", "Creating", "Updating", "Deleting", "Moving", "PartiallySucceeded", + "PartiallyConnected", "InProgress", "Accepted", "Provisioning", and + "UpgradeFailedRollbackSucceeded". + :vartype aggregate_state: str or ~azure.mgmt.azurestackhci.models.ExtensionAggregateState + :ivar per_node_extension_details: State of Arc Extension in each of the nodes. + :vartype per_node_extension_details: + list[~azure.mgmt.azurestackhci.models.PerNodeExtensionState] + :ivar managed_by: Indicates if the extension is managed by azure or the user. Known values are: + "Azure" and "User". + :vartype managed_by: str or ~azure.mgmt.azurestackhci.models.ExtensionManagedBy + :ivar force_update_tag: How the extension handler should be forced to update even if the + extension configuration has not changed. + :vartype force_update_tag: str + :ivar publisher: The name of the extension handler publisher. + :vartype publisher: str + :ivar type_properties_extension_parameters_type: Specifies the type of the extension; an + example is "CustomScriptExtension". + :vartype type_properties_extension_parameters_type: str + :ivar type_handler_version: Specifies the version of the script handler. Latest version would + be used if not specified. + :vartype type_handler_version: str + :ivar auto_upgrade_minor_version: Indicates whether the extension should use a newer minor + version if one is available at deployment time. Once deployed, however, the extension will not + upgrade minor versions unless redeployed, even with this property set to true. + :vartype auto_upgrade_minor_version: bool + :ivar settings: Json formatted public settings for the extension. + :vartype settings: JSON + :ivar protected_settings: Protected settings (may contain secrets). + :vartype protected_settings: JSON + :ivar enable_automatic_upgrade: Indicates whether the extension should be automatically + upgraded by the platform if there is a newer version available. + :vartype enable_automatic_upgrade: bool """ _validation = { @@ -1005,8 +1910,10 @@ class HybridIdentityMetadata(ProxyResource): "name": {"readonly": True}, "type": {"readonly": True}, "system_data": {"readonly": True}, - "identity": {"readonly": True}, "provisioning_state": {"readonly": True}, + "aggregate_state": {"readonly": True}, + "per_node_extension_details": {"readonly": True}, + "managed_by": {"readonly": True}, } _attribute_map = { @@ -1014,96 +1921,119 @@ class HybridIdentityMetadata(ProxyResource): "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "system_data": {"key": "systemData", "type": "SystemData"}, - "resource_uid": {"key": "properties.resourceUid", "type": "str"}, - "public_key": {"key": "properties.publicKey", "type": "str"}, - "identity": {"key": "properties.identity", "type": "Identity"}, "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__(self, *, resource_uid: Optional[str] = None, public_key: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword resource_uid: The unique identifier for the resource. - :paramtype resource_uid: str - :keyword public_key: The Public Key. - :paramtype public_key: str - """ - super().__init__(**kwargs) - self.resource_uid = resource_uid - self.public_key = public_key - self.identity = None - self.provisioning_state = None - - -class HybridIdentityMetadataList(_serialization.Model): - """List of HybridIdentityMetadata. - - All required parameters must be populated in order to send to Azure. - - :ivar next_link: Url to follow for getting next page of HybridIdentityMetadata. - :vartype next_link: str - :ivar value: Array of HybridIdentityMetadata. Required. - :vartype value: list[~azure.mgmt.azurestackhci.models.HybridIdentityMetadata] - """ - - _validation = { - "value": {"required": True}, - } - - _attribute_map = { - "next_link": {"key": "nextLink", "type": "str"}, - "value": {"key": "value", "type": "[HybridIdentityMetadata]"}, + "aggregate_state": {"key": "properties.aggregateState", "type": "str"}, + "per_node_extension_details": {"key": "properties.perNodeExtensionDetails", "type": "[PerNodeExtensionState]"}, + "managed_by": {"key": "properties.managedBy", "type": "str"}, + "force_update_tag": {"key": "properties.extensionParameters.forceUpdateTag", "type": "str"}, + "publisher": {"key": "properties.extensionParameters.publisher", "type": "str"}, + "type_properties_extension_parameters_type": {"key": "properties.extensionParameters.type", "type": "str"}, + "type_handler_version": {"key": "properties.extensionParameters.typeHandlerVersion", "type": "str"}, + "auto_upgrade_minor_version": {"key": "properties.extensionParameters.autoUpgradeMinorVersion", "type": "bool"}, + "settings": {"key": "properties.extensionParameters.settings", "type": "object"}, + "protected_settings": {"key": "properties.extensionParameters.protectedSettings", "type": "object"}, + "enable_automatic_upgrade": {"key": "properties.extensionParameters.enableAutomaticUpgrade", "type": "bool"}, } def __init__( - self, *, value: List["_models.HybridIdentityMetadata"], next_link: Optional[str] = None, **kwargs: Any + self, + *, + force_update_tag: Optional[str] = None, + publisher: Optional[str] = None, + type_properties_extension_parameters_type: Optional[str] = None, + type_handler_version: Optional[str] = None, + auto_upgrade_minor_version: Optional[bool] = None, + settings: Optional[JSON] = None, + protected_settings: Optional[JSON] = None, + enable_automatic_upgrade: Optional[bool] = None, + **kwargs: Any ) -> None: """ - :keyword next_link: Url to follow for getting next page of HybridIdentityMetadata. - :paramtype next_link: str - :keyword value: Array of HybridIdentityMetadata. Required. - :paramtype value: list[~azure.mgmt.azurestackhci.models.HybridIdentityMetadata] + :keyword force_update_tag: How the extension handler should be forced to update even if the + extension configuration has not changed. + :paramtype force_update_tag: str + :keyword publisher: The name of the extension handler publisher. + :paramtype publisher: str + :keyword type_properties_extension_parameters_type: Specifies the type of the extension; an + example is "CustomScriptExtension". + :paramtype type_properties_extension_parameters_type: str + :keyword type_handler_version: Specifies the version of the script handler. Latest version + would be used if not specified. + :paramtype type_handler_version: str + :keyword auto_upgrade_minor_version: Indicates whether the extension should use a newer minor + version if one is available at deployment time. Once deployed, however, the extension will not + upgrade minor versions unless redeployed, even with this property set to true. + :paramtype auto_upgrade_minor_version: bool + :keyword settings: Json formatted public settings for the extension. + :paramtype settings: JSON + :keyword protected_settings: Protected settings (may contain secrets). + :paramtype protected_settings: JSON + :keyword enable_automatic_upgrade: Indicates whether the extension should be automatically + upgraded by the platform if there is a newer version available. + :paramtype enable_automatic_upgrade: bool """ super().__init__(**kwargs) - self.next_link = next_link - self.value = value - + self.provisioning_state = None + self.aggregate_state = None + self.per_node_extension_details = None + self.managed_by = None + self.force_update_tag = force_update_tag + self.publisher = publisher + self.type_properties_extension_parameters_type = type_properties_extension_parameters_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.enable_automatic_upgrade = enable_automatic_upgrade -class Identity(_serialization.Model): - """Identity for the resource. - Variables are only populated by the server, and will be ignored when sending a request. +class ExtensionInstanceView(_serialization.Model): + """Describes the Extension Instance View. - :ivar principal_id: The principal ID of resource identity. - :vartype principal_id: str - :ivar tenant_id: The tenant ID of resource. - :vartype tenant_id: str - :ivar type: The identity type. Default value is "SystemAssigned". + :ivar name: The extension name. + :vartype name: str + :ivar type: Specifies the type of the extension; an example is "MicrosoftMonitoringAgent". :vartype type: str + :ivar type_handler_version: Specifies the version of the script handler. + :vartype type_handler_version: str + :ivar status: Instance view status. + :vartype status: ~azure.mgmt.azurestackhci.models.ExtensionInstanceViewStatus """ - _validation = { - "principal_id": {"readonly": True}, - "tenant_id": {"readonly": True}, - } - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "tenant_id": {"key": "tenantId", "type": "str"}, + "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, + "type_handler_version": {"key": "typeHandlerVersion", "type": "str"}, + "status": {"key": "status", "type": "ExtensionInstanceViewStatus"}, } - def __init__(self, *, type: Optional[Literal["SystemAssigned"]] = None, **kwargs: Any) -> None: + def __init__( + self, + *, + name: Optional[str] = None, + type: Optional[str] = None, + type_handler_version: Optional[str] = None, + status: Optional["_models.ExtensionInstanceViewStatus"] = None, + **kwargs: Any + ) -> None: """ - :keyword type: The identity type. Default value is "SystemAssigned". + :keyword name: The extension name. + :paramtype name: str + :keyword type: Specifies the type of the extension; an example is "MicrosoftMonitoringAgent". :paramtype type: str + :keyword type_handler_version: Specifies the version of the script handler. + :paramtype type_handler_version: str + :keyword status: Instance view status. + :paramtype status: ~azure.mgmt.azurestackhci.models.ExtensionInstanceViewStatus """ super().__init__(**kwargs) - self.principal_id = None - self.tenant_id = None + self.name = name self.type = type + self.type_handler_version = type_handler_version + self.status = status -class InstanceViewStatus(_serialization.Model): +class ExtensionInstanceViewStatus(_serialization.Model): """Instance view status. :ivar code: The status code. @@ -1156,244 +2086,200 @@ def __init__( self.time = time -class InterfaceDNSSettings(_serialization.Model): - """InterfaceDNSSettings. +class ExtensionList(_serialization.Model): + """List of Extensions in HCI cluster. - :ivar dns_servers: List of DNS server IP Addresses for the interface. - :vartype dns_servers: list[str] + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of Extensions in HCI cluster. + :vartype value: list[~azure.mgmt.azurestackhci.models.Extension] + :ivar next_link: Link to the next set of results. + :vartype next_link: str """ - _attribute_map = { - "dns_servers": {"key": "dnsServers", "type": "[str]"}, + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, } - def __init__(self, *, dns_servers: Optional[List[str]] = None, **kwargs: Any) -> None: - """ - :keyword dns_servers: List of DNS server IP Addresses for the interface. - :paramtype dns_servers: list[str] - """ + _attribute_map = { + "value": {"key": "value", "type": "[Extension]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ super().__init__(**kwargs) - self.dns_servers = dns_servers + self.value = None + self.next_link = None -class IPConfiguration(_serialization.Model): - """InterfaceIPConfiguration iPConfiguration in a network interface. +class ExtensionPatch(_serialization.Model): + """Extension Details to update. - :ivar name: Name - The name of the resource that is unique within a resource group. This name - can be used to access the resource. - :vartype name: str - :ivar properties: InterfaceIPConfigurationPropertiesFormat properties of IP configuration. - :vartype properties: ~azure.mgmt.azurestackhci.models.IPConfigurationProperties + :ivar extension_parameters: Describes the properties of a Machine Extension that can be + updated. + :vartype extension_parameters: ~azure.mgmt.azurestackhci.models.ExtensionPatchParameters """ - _validation = { - "name": {"pattern": r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-._a-zA-Z0-9]{0,78}[_a-zA-Z0-9]$"}, - } - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "properties": {"key": "properties", "type": "IPConfigurationProperties"}, + "extension_parameters": {"key": "properties.extensionParameters", "type": "ExtensionPatchParameters"}, } def __init__( - self, - *, - name: Optional[str] = None, - properties: Optional["_models.IPConfigurationProperties"] = None, - **kwargs: Any + self, *, extension_parameters: Optional["_models.ExtensionPatchParameters"] = None, **kwargs: Any ) -> None: """ - :keyword name: Name - The name of the resource that is unique within a resource group. This - name can be used to access the resource. - :paramtype name: str - :keyword properties: InterfaceIPConfigurationPropertiesFormat properties of IP configuration. - :paramtype properties: ~azure.mgmt.azurestackhci.models.IPConfigurationProperties + :keyword extension_parameters: Describes the properties of a Machine Extension that can be + updated. + :paramtype extension_parameters: ~azure.mgmt.azurestackhci.models.ExtensionPatchParameters """ super().__init__(**kwargs) - self.name = name - self.properties = properties - - -class IPConfigurationProperties(_serialization.Model): - """InterfaceIPConfigurationPropertiesFormat properties of IP configuration. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar gateway: Gateway for network interface. - :vartype gateway: str - :ivar prefix_length: prefixLength for network interface. - :vartype prefix_length: str - :ivar private_ip_address: PrivateIPAddress - Private IP address of the IP configuration. - :vartype private_ip_address: str - :ivar subnet: Subnet - Name of Subnet bound to the IP configuration. - :vartype subnet: ~azure.mgmt.azurestackhci.models.IPConfigurationPropertiesSubnet + self.extension_parameters = extension_parameters + + +class ExtensionPatchParameters(_serialization.Model): + """Describes the properties of a Machine Extension that can be updated. + + :ivar type_handler_version: Specifies the version of the script handler. Latest version would + be used if not specified. + :vartype type_handler_version: str + :ivar enable_automatic_upgrade: Indicates whether the extension should be automatically + upgraded by the platform if there is a newer version available. + :vartype enable_automatic_upgrade: bool + :ivar settings: Json formatted public settings for the extension. + :vartype settings: JSON + :ivar protected_settings: Protected settings (may contain secrets). + :vartype protected_settings: JSON """ - _validation = { - "gateway": {"readonly": True}, - "prefix_length": {"readonly": True}, - } - _attribute_map = { - "gateway": {"key": "gateway", "type": "str"}, - "prefix_length": {"key": "prefixLength", "type": "str"}, - "private_ip_address": {"key": "privateIPAddress", "type": "str"}, - "subnet": {"key": "subnet", "type": "IPConfigurationPropertiesSubnet"}, + "type_handler_version": {"key": "typeHandlerVersion", "type": "str"}, + "enable_automatic_upgrade": {"key": "enableAutomaticUpgrade", "type": "bool"}, + "settings": {"key": "settings", "type": "object"}, + "protected_settings": {"key": "protectedSettings", "type": "object"}, } def __init__( self, *, - private_ip_address: Optional[str] = None, - subnet: Optional["_models.IPConfigurationPropertiesSubnet"] = None, + type_handler_version: Optional[str] = None, + enable_automatic_upgrade: Optional[bool] = None, + settings: Optional[JSON] = None, + protected_settings: Optional[JSON] = None, **kwargs: Any ) -> None: """ - :keyword private_ip_address: PrivateIPAddress - Private IP address of the IP configuration. - :paramtype private_ip_address: str - :keyword subnet: Subnet - Name of Subnet bound to the IP configuration. - :paramtype subnet: ~azure.mgmt.azurestackhci.models.IPConfigurationPropertiesSubnet - """ - super().__init__(**kwargs) - self.gateway = None - self.prefix_length = None - self.private_ip_address = private_ip_address - self.subnet = subnet - - -class IPConfigurationPropertiesSubnet(_serialization.Model): - """Subnet - Name of Subnet bound to the IP configuration. - - :ivar id: ID - The ARM resource id in the form of - /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/... - :vartype id: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: ID - The ARM resource id in the form of - /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/... - :paramtype id: str + :keyword type_handler_version: Specifies the version of the script handler. Latest version + would be used if not specified. + :paramtype type_handler_version: str + :keyword enable_automatic_upgrade: Indicates whether the extension should be automatically + upgraded by the platform if there is a newer version available. + :paramtype enable_automatic_upgrade: bool + :keyword settings: Json formatted public settings for the extension. + :paramtype settings: JSON + :keyword protected_settings: Protected settings (may contain secrets). + :paramtype protected_settings: JSON """ super().__init__(**kwargs) - self.id = id + self.type_handler_version = type_handler_version + self.enable_automatic_upgrade = enable_automatic_upgrade + self.settings = settings + self.protected_settings = protected_settings -class IPPool(_serialization.Model): - """IPPool. +class ExtensionUpgradeParameters(_serialization.Model): + """Describes the parameters for Extension upgrade. - :ivar name: Name of the IP-Pool. - :vartype name: str - :ivar ip_pool_type: Type of the IP Pool [vm, vippool]. Known values are: "vm" and "vippool". - :vartype ip_pool_type: str or ~azure.mgmt.azurestackhci.models.IPPoolTypeEnum - :ivar start: Start of the IP address pool. - :vartype start: str - :ivar end: End of the IP address pool. - :vartype end: str - :ivar info: - :vartype info: ~azure.mgmt.azurestackhci.models.IPPoolInfo + :ivar target_version: Extension Upgrade Target Version. + :vartype target_version: str """ _attribute_map = { - "name": {"key": "name", "type": "str"}, - "ip_pool_type": {"key": "ipPoolType", "type": "str"}, - "start": {"key": "start", "type": "str"}, - "end": {"key": "end", "type": "str"}, - "info": {"key": "info", "type": "IPPoolInfo"}, + "target_version": {"key": "targetVersion", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - ip_pool_type: Optional[Union[str, "_models.IPPoolTypeEnum"]] = None, - start: Optional[str] = None, - end: Optional[str] = None, - info: Optional["_models.IPPoolInfo"] = None, - **kwargs: Any - ) -> None: + def __init__(self, *, target_version: Optional[str] = None, **kwargs: Any) -> None: """ - :keyword name: Name of the IP-Pool. - :paramtype name: str - :keyword ip_pool_type: Type of the IP Pool [vm, vippool]. Known values are: "vm" and "vippool". - :paramtype ip_pool_type: str or ~azure.mgmt.azurestackhci.models.IPPoolTypeEnum - :keyword start: Start of the IP address pool. - :paramtype start: str - :keyword end: End of the IP address pool. - :paramtype end: str - :keyword info: - :paramtype info: ~azure.mgmt.azurestackhci.models.IPPoolInfo + :keyword target_version: Extension Upgrade Target Version. + :paramtype target_version: str """ super().__init__(**kwargs) - self.name = name - self.ip_pool_type = ip_pool_type - self.start = start - self.end = end - self.info = info + self.target_version = target_version -class IPPoolInfo(_serialization.Model): - """IPPoolInfo. +class GalleryDiskImage(_serialization.Model): + """This is the disk image base class. Variables are only populated by the server, and will be ignored when sending a request. - :ivar used: Number of IP addresses allocated from the IP Pool. - :vartype used: str - :ivar available: Number of IP addresses available in the IP Pool. - :vartype available: str + :ivar size_in_mb: This property indicates the size of the VHD to be created. + :vartype size_in_mb: int """ _validation = { - "used": {"readonly": True}, - "available": {"readonly": True}, + "size_in_mb": {"readonly": True}, } _attribute_map = { - "used": {"key": "used", "type": "str"}, - "available": {"key": "available", "type": "str"}, + "size_in_mb": {"key": "sizeInMB", "type": "int"}, } def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.used = None - self.available = None + self.size_in_mb = None -class LogicalNetworkPropertiesDhcpOptions(_serialization.Model): - """DhcpOptions contains an array of DNS servers available to VMs deployed in the logical network. - Standard DHCP option for a subnet overrides logical network DHCP options. +class GalleryImageIdentifier(_serialization.Model): + """This is the gallery image definition identifier. - :ivar dns_servers: The list of DNS servers IP addresses. - :vartype dns_servers: list[str] + All required parameters must be populated in order to send to server. + + :ivar publisher: The name of the gallery image definition publisher. Required. + :vartype publisher: str + :ivar offer: The name of the gallery image definition offer. Required. + :vartype offer: str + :ivar sku: The name of the gallery image definition SKU. Required. + :vartype sku: str """ + _validation = { + "publisher": {"required": True}, + "offer": {"required": True}, + "sku": {"required": True}, + } + _attribute_map = { - "dns_servers": {"key": "dnsServers", "type": "[str]"}, + "publisher": {"key": "publisher", "type": "str"}, + "offer": {"key": "offer", "type": "str"}, + "sku": {"key": "sku", "type": "str"}, } - def __init__(self, *, dns_servers: Optional[List[str]] = None, **kwargs: Any) -> None: + def __init__(self, *, publisher: str, offer: str, sku: str, **kwargs: Any) -> None: """ - :keyword dns_servers: The list of DNS servers IP addresses. - :paramtype dns_servers: list[str] + :keyword publisher: The name of the gallery image definition publisher. Required. + :paramtype publisher: str + :keyword offer: The name of the gallery image definition offer. Required. + :paramtype offer: str + :keyword sku: The name of the gallery image definition SKU. Required. + :paramtype sku: str """ super().__init__(**kwargs) - self.dns_servers = dns_servers + self.publisher = publisher + self.offer = offer + self.sku = sku -class LogicalNetworks(TrackedResource): # pylint: disable=too-many-instance-attributes - """The logical network resource definition. +class GalleryImages(TrackedResource): # pylint: disable=too-many-instance-attributes + """The gallery images resource 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. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -1409,18 +2295,29 @@ class LogicalNetworks(TrackedResource): # pylint: disable=too-many-instance-att :vartype location: str :ivar extended_location: The extendedLocation of the resource. :vartype extended_location: ~azure.mgmt.azurestackhci.models.ExtendedLocation - :ivar dhcp_options: DhcpOptions contains an array of DNS servers available to VMs deployed in - the logical network. Standard DHCP option for a subnet overrides logical network DHCP options. - :vartype dhcp_options: ~azure.mgmt.azurestackhci.models.LogicalNetworkPropertiesDhcpOptions - :ivar subnets: Subnet - list of subnets under the logical network. - :vartype subnets: list[~azure.mgmt.azurestackhci.models.Subnet] - :ivar provisioning_state: Provisioning state of the logical network. Known values are: + :ivar container_id: Storage ContainerID of the storage container to be used for gallery image. + :vartype container_id: str + :ivar image_path: location of the image the gallery image should be created from. + :vartype image_path: str + :ivar os_type: Operating system type that the gallery image uses [Windows, Linux]. Known values + are: "Windows" and "Linux". + :vartype os_type: str or ~azure.mgmt.azurestackhci.models.OperatingSystemTypes + :ivar cloud_init_data_source: Datasource for the gallery image when provisioning with + cloud-init [NoCloud, Azure]. Known values are: "NoCloud" and "Azure". + :vartype cloud_init_data_source: str or ~azure.mgmt.azurestackhci.models.CloudInitDataSource + :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine [V1, V2]. Known + values are: "V1" and "V2". + :vartype hyper_v_generation: str or ~azure.mgmt.azurestackhci.models.HyperVGeneration + :ivar identifier: This is the gallery image definition identifier. + :vartype identifier: ~azure.mgmt.azurestackhci.models.GalleryImageIdentifier + :ivar version: Specifies information about the gallery image version that you want to create or + update. + :vartype version: ~azure.mgmt.azurestackhci.models.GalleryImageVersion + :ivar provisioning_state: Provisioning state of the gallery image. Known values are: "Succeeded", "Failed", "InProgress", "Accepted", "Deleting", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.azurestackhci.models.ProvisioningStateEnum - :ivar vm_switch_name: name of the network switch to be used for VMs. - :vartype vm_switch_name: str - :ivar status: The observed state of logical networks. - :vartype status: ~azure.mgmt.azurestackhci.models.LogicalNetworkStatus + :ivar status: The observed state of gallery images. + :vartype status: ~azure.mgmt.azurestackhci.models.GalleryImageStatus """ _validation = { @@ -1441,11 +2338,15 @@ class LogicalNetworks(TrackedResource): # pylint: disable=too-many-instance-att "tags": {"key": "tags", "type": "{str}"}, "location": {"key": "location", "type": "str"}, "extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"}, - "dhcp_options": {"key": "properties.dhcpOptions", "type": "LogicalNetworkPropertiesDhcpOptions"}, - "subnets": {"key": "properties.subnets", "type": "[Subnet]"}, + "container_id": {"key": "properties.containerId", "type": "str"}, + "image_path": {"key": "properties.imagePath", "type": "str"}, + "os_type": {"key": "properties.osType", "type": "str"}, + "cloud_init_data_source": {"key": "properties.cloudInitDataSource", "type": "str"}, + "hyper_v_generation": {"key": "properties.hyperVGeneration", "type": "str"}, + "identifier": {"key": "properties.identifier", "type": "GalleryImageIdentifier"}, + "version": {"key": "properties.version", "type": "GalleryImageVersion"}, "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "vm_switch_name": {"key": "properties.vmSwitchName", "type": "str"}, - "status": {"key": "properties.status", "type": "LogicalNetworkStatus"}, + "status": {"key": "properties.status", "type": "GalleryImageStatus"}, } def __init__( @@ -1454,9 +2355,13 @@ def __init__( location: str, tags: Optional[Dict[str, str]] = None, extended_location: Optional["_models.ExtendedLocation"] = None, - dhcp_options: Optional["_models.LogicalNetworkPropertiesDhcpOptions"] = None, - subnets: Optional[List["_models.Subnet"]] = None, - vm_switch_name: Optional[str] = None, + container_id: Optional[str] = None, + image_path: Optional[str] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + cloud_init_data_source: Optional[Union[str, "_models.CloudInitDataSource"]] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, + identifier: Optional["_models.GalleryImageIdentifier"] = None, + version: Optional["_models.GalleryImageVersion"] = None, **kwargs: Any ) -> None: """ @@ -1466,68 +2371,91 @@ def __init__( :paramtype location: str :keyword extended_location: The extendedLocation of the resource. :paramtype extended_location: ~azure.mgmt.azurestackhci.models.ExtendedLocation - :keyword dhcp_options: DhcpOptions contains an array of DNS servers available to VMs deployed - in the logical network. Standard DHCP option for a subnet overrides logical network DHCP - options. - :paramtype dhcp_options: ~azure.mgmt.azurestackhci.models.LogicalNetworkPropertiesDhcpOptions - :keyword subnets: Subnet - list of subnets under the logical network. - :paramtype subnets: list[~azure.mgmt.azurestackhci.models.Subnet] - :keyword vm_switch_name: name of the network switch to be used for VMs. - :paramtype vm_switch_name: str + :keyword container_id: Storage ContainerID of the storage container to be used for gallery + image. + :paramtype container_id: str + :keyword image_path: location of the image the gallery image should be created from. + :paramtype image_path: str + :keyword os_type: Operating system type that the gallery image uses [Windows, Linux]. Known + values are: "Windows" and "Linux". + :paramtype os_type: str or ~azure.mgmt.azurestackhci.models.OperatingSystemTypes + :keyword cloud_init_data_source: Datasource for the gallery image when provisioning with + cloud-init [NoCloud, Azure]. Known values are: "NoCloud" and "Azure". + :paramtype cloud_init_data_source: str or ~azure.mgmt.azurestackhci.models.CloudInitDataSource + :keyword hyper_v_generation: The hypervisor generation of the Virtual Machine [V1, V2]. Known + values are: "V1" and "V2". + :paramtype hyper_v_generation: str or ~azure.mgmt.azurestackhci.models.HyperVGeneration + :keyword identifier: This is the gallery image definition identifier. + :paramtype identifier: ~azure.mgmt.azurestackhci.models.GalleryImageIdentifier + :keyword version: Specifies information about the gallery image version that you want to create + or update. + :paramtype version: ~azure.mgmt.azurestackhci.models.GalleryImageVersion """ super().__init__(tags=tags, location=location, **kwargs) self.extended_location = extended_location - self.dhcp_options = dhcp_options - self.subnets = subnets + self.container_id = container_id + self.image_path = image_path + self.os_type = os_type + self.cloud_init_data_source = cloud_init_data_source + self.hyper_v_generation = hyper_v_generation + self.identifier = identifier + self.version = version self.provisioning_state = None - self.vm_switch_name = vm_switch_name self.status = None -class LogicalNetworksListResult(_serialization.Model): - """LogicalNetworksListResult. +class GalleryImagesListResult(_serialization.Model): + """List of gallery images. + + Variables are only populated by the server, and will be ignored when sending a request. :ivar value: - :vartype value: list[~azure.mgmt.azurestackhci.models.LogicalNetworks] - :ivar next_link: + :vartype value: list[~azure.mgmt.azurestackhci.models.GalleryImages] + :ivar next_link: Link to the next set of results. :vartype next_link: str """ + _validation = { + "next_link": {"readonly": True}, + } + _attribute_map = { - "value": {"key": "value", "type": "[LogicalNetworks]"}, + "value": {"key": "value", "type": "[GalleryImages]"}, "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, *, value: Optional[List["_models.LogicalNetworks"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: + def __init__(self, *, value: Optional[List["_models.GalleryImages"]] = None, **kwargs: Any) -> None: """ :keyword value: - :paramtype value: list[~azure.mgmt.azurestackhci.models.LogicalNetworks] - :keyword next_link: - :paramtype next_link: str + :paramtype value: list[~azure.mgmt.azurestackhci.models.GalleryImages] """ super().__init__(**kwargs) self.value = value - self.next_link = next_link + self.next_link = None -class LogicalNetworkStatus(_serialization.Model): - """The observed state of logical networks. +class GalleryImageStatus(_serialization.Model): + """The observed state of gallery images. - :ivar error_code: LogicalNetwork provisioning error code. + :ivar error_code: GalleryImage provisioning error code. :vartype error_code: str :ivar error_message: Descriptive error message. :vartype error_message: str :ivar provisioning_status: :vartype provisioning_status: - ~azure.mgmt.azurestackhci.models.LogicalNetworkStatusProvisioningStatus + ~azure.mgmt.azurestackhci.models.GalleryImageStatusProvisioningStatus + :ivar download_status: The download status of the gallery image. + :vartype download_status: ~azure.mgmt.azurestackhci.models.GalleryImageStatusDownloadStatus + :ivar progress_percentage: The progress of the operation in percentage. + :vartype progress_percentage: int """ _attribute_map = { "error_code": {"key": "errorCode", "type": "str"}, "error_message": {"key": "errorMessage", "type": "str"}, - "provisioning_status": {"key": "provisioningStatus", "type": "LogicalNetworkStatusProvisioningStatus"}, + "provisioning_status": {"key": "provisioningStatus", "type": "GalleryImageStatusProvisioningStatus"}, + "download_status": {"key": "downloadStatus", "type": "GalleryImageStatusDownloadStatus"}, + "progress_percentage": {"key": "progressPercentage", "type": "int"}, } def __init__( @@ -1535,31 +2463,62 @@ def __init__( *, error_code: Optional[str] = None, error_message: Optional[str] = None, - provisioning_status: Optional["_models.LogicalNetworkStatusProvisioningStatus"] = None, + provisioning_status: Optional["_models.GalleryImageStatusProvisioningStatus"] = None, + download_status: Optional["_models.GalleryImageStatusDownloadStatus"] = None, + progress_percentage: Optional[int] = None, **kwargs: Any ) -> None: """ - :keyword error_code: LogicalNetwork provisioning error code. + :keyword error_code: GalleryImage provisioning error code. :paramtype error_code: str :keyword error_message: Descriptive error message. :paramtype error_message: str :keyword provisioning_status: :paramtype provisioning_status: - ~azure.mgmt.azurestackhci.models.LogicalNetworkStatusProvisioningStatus + ~azure.mgmt.azurestackhci.models.GalleryImageStatusProvisioningStatus + :keyword download_status: The download status of the gallery image. + :paramtype download_status: ~azure.mgmt.azurestackhci.models.GalleryImageStatusDownloadStatus + :keyword progress_percentage: The progress of the operation in percentage. + :paramtype progress_percentage: int """ super().__init__(**kwargs) self.error_code = error_code self.error_message = error_message self.provisioning_status = provisioning_status + self.download_status = download_status + self.progress_percentage = progress_percentage -class LogicalNetworkStatusProvisioningStatus(_serialization.Model): - """LogicalNetworkStatusProvisioningStatus. +class GalleryImageStatusDownloadStatus(_serialization.Model): + """The download status of the gallery image. - :ivar operation_id: The ID of the operation performed on the logical network. + :ivar download_size_in_mb: The downloaded sized of the image in MB. + :vartype download_size_in_mb: int + """ + + _attribute_map = { + "download_size_in_mb": {"key": "downloadSizeInMB", "type": "int"}, + } + + def __init__(self, *, download_size_in_mb: Optional[int] = None, **kwargs: Any) -> None: + """ + :keyword download_size_in_mb: The downloaded sized of the image in MB. + :paramtype download_size_in_mb: int + """ + super().__init__(**kwargs) + self.download_size_in_mb = download_size_in_mb + + +class GalleryImageStatusProvisioningStatus(_serialization.Model): + """GalleryImageStatusProvisioningStatus. + + :ivar operation_id: The ID of the operation performed on the gallery image. :vartype operation_id: str - :ivar status: The status of the operation performed on the logical network [Succeeded, Failed, - InProgress]. Known values are: "Succeeded", "Failed", and "InProgress". + :ivar status: The status of the operation performed on the gallery image [Succeeded, Failed, + InProgress]. Known values are: "NotYetRegistered", "ConnectedRecently", "NotConnectedRecently", + "Disconnected", "Error", "NotSpecified", "ValidationInProgress", "ValidationSuccess", + "ValidationFailed", "DeploymentInProgress", "DeploymentFailed", "DeploymentSuccess", + "Succeeded", "Failed", and "InProgress". :vartype status: str or ~azure.mgmt.azurestackhci.models.Status """ @@ -1576,10 +2535,13 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword operation_id: The ID of the operation performed on the logical network. + :keyword operation_id: The ID of the operation performed on the gallery image. :paramtype operation_id: str - :keyword status: The status of the operation performed on the logical network [Succeeded, - Failed, InProgress]. Known values are: "Succeeded", "Failed", and "InProgress". + :keyword status: The status of the operation performed on the gallery image [Succeeded, Failed, + InProgress]. Known values are: "NotYetRegistered", "ConnectedRecently", "NotConnectedRecently", + "Disconnected", "Error", "NotSpecified", "ValidationInProgress", "ValidationSuccess", + "ValidationFailed", "DeploymentInProgress", "DeploymentFailed", "DeploymentSuccess", + "Succeeded", "Failed", and "InProgress". :paramtype status: str or ~azure.mgmt.azurestackhci.models.Status """ super().__init__(**kwargs) @@ -1587,8 +2549,8 @@ def __init__( self.status = status -class LogicalNetworksUpdateRequest(_serialization.Model): - """The logical network resource patch definition. +class GalleryImagesUpdateRequest(_serialization.Model): + """The gallery images resource patch definition. :ivar tags: Resource tags. :vartype tags: dict[str, str] @@ -1607,15 +2569,75 @@ def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> N self.tags = tags -class MarketplaceGalleryImages(TrackedResource): # pylint: disable=too-many-instance-attributes - """The marketplace gallery image resource definition. +class GalleryImageVersion(_serialization.Model): + """Specifies information about the gallery image version that you want to create or update. + + :ivar name: This is the version of the gallery image. + :vartype name: str + :ivar storage_profile: This is the storage profile of a Gallery Image Version. + :vartype storage_profile: ~azure.mgmt.azurestackhci.models.GalleryImageVersionStorageProfile + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "storage_profile": {"key": "properties.storageProfile", "type": "GalleryImageVersionStorageProfile"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + storage_profile: Optional["_models.GalleryImageVersionStorageProfile"] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: This is the version of the gallery image. + :paramtype name: str + :keyword storage_profile: This is the storage profile of a Gallery Image Version. + :paramtype storage_profile: ~azure.mgmt.azurestackhci.models.GalleryImageVersionStorageProfile + """ + super().__init__(**kwargs) + self.name = name + self.storage_profile = storage_profile + + +class GalleryImageVersionStorageProfile(_serialization.Model): + """This is the storage profile of a Gallery Image Version. + + :ivar os_disk_image: This is the OS disk image. + :vartype os_disk_image: ~azure.mgmt.azurestackhci.models.GalleryOSDiskImage + """ + + _attribute_map = { + "os_disk_image": {"key": "osDiskImage", "type": "GalleryOSDiskImage"}, + } + + def __init__(self, *, os_disk_image: Optional["_models.GalleryOSDiskImage"] = None, **kwargs: Any) -> None: + """ + :keyword os_disk_image: This is the OS disk image. + :paramtype os_disk_image: ~azure.mgmt.azurestackhci.models.GalleryOSDiskImage + """ + super().__init__(**kwargs) + self.os_disk_image = os_disk_image + + +class GalleryOSDiskImage(GalleryDiskImage): + """This is the OS disk image. 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 size_in_mb: This property indicates the size of the VHD to be created. + :vartype size_in_mb: int + """ + + +class GuestAgent(ProxyResource): + """Defines the GuestAgent. + + Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -1625,34 +2647,15 @@ class MarketplaceGalleryImages(TrackedResource): # pylint: disable=too-many-ins :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.azurestackhci.models.SystemData - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar location: The geo-location where the resource lives. Required. - :vartype location: str - :ivar extended_location: The extendedLocation of the resource. - :vartype extended_location: ~azure.mgmt.azurestackhci.models.ExtendedLocation - :ivar container_id: Storage ContainerID of the storage container to be used for marketplace - gallery image. - :vartype container_id: str - :ivar os_type: Operating system type that the gallery image uses [Windows, Linux]. Known values - are: "Windows" and "Linux". - :vartype os_type: str or ~azure.mgmt.azurestackhci.models.OperatingSystemTypes - :ivar cloud_init_data_source: Datasource for the gallery image when provisioning with - cloud-init [NoCloud, Azure]. Known values are: "NoCloud" and "Azure". - :vartype cloud_init_data_source: str or ~azure.mgmt.azurestackhci.models.CloudInitDataSource - :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine [V1, V2]. Known - values are: "V1" and "V2". - :vartype hyper_v_generation: str or ~azure.mgmt.azurestackhci.models.HyperVGeneration - :ivar identifier: This is the gallery image definition identifier. - :vartype identifier: ~azure.mgmt.azurestackhci.models.GalleryImageIdentifier - :ivar version: Specifies information about the gallery image version that you want to create or - update. - :vartype version: ~azure.mgmt.azurestackhci.models.GalleryImageVersion - :ivar provisioning_state: Provisioning state of the marketplace gallery image. Known values - are: "Succeeded", "Failed", "InProgress", "Accepted", "Deleting", and "Canceled". - :vartype provisioning_state: str or ~azure.mgmt.azurestackhci.models.ProvisioningStateEnum - :ivar status: The observed state of marketplace gallery images. - :vartype status: ~azure.mgmt.azurestackhci.models.MarketplaceGalleryImageStatus + :ivar credentials: Username / Password Credentials to provision guest agent. + :vartype credentials: ~azure.mgmt.azurestackhci.models.GuestCredential + :ivar provisioning_action: The guest agent provisioning action. Known values are: "install", + "uninstall", and "repair". + :vartype provisioning_action: str or ~azure.mgmt.azurestackhci.models.ProvisioningAction + :ivar status: The guest agent status. + :vartype status: str + :ivar provisioning_state: The provisioning state. + :vartype provisioning_state: str """ _validation = { @@ -1660,9 +2663,8 @@ class MarketplaceGalleryImages(TrackedResource): # pylint: disable=too-many-ins "name": {"readonly": True}, "type": {"readonly": True}, "system_data": {"readonly": True}, - "location": {"required": True}, - "provisioning_state": {"readonly": True}, "status": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { @@ -1670,242 +2672,3451 @@ class MarketplaceGalleryImages(TrackedResource): # pylint: disable=too-many-ins "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "system_data": {"key": "systemData", "type": "SystemData"}, - "tags": {"key": "tags", "type": "{str}"}, - "location": {"key": "location", "type": "str"}, - "extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"}, - "container_id": {"key": "properties.containerId", "type": "str"}, - "os_type": {"key": "properties.osType", "type": "str"}, - "cloud_init_data_source": {"key": "properties.cloudInitDataSource", "type": "str"}, - "hyper_v_generation": {"key": "properties.hyperVGeneration", "type": "str"}, - "identifier": {"key": "properties.identifier", "type": "GalleryImageIdentifier"}, - "version": {"key": "properties.version", "type": "GalleryImageVersion"}, + "credentials": {"key": "properties.credentials", "type": "GuestCredential"}, + "provisioning_action": {"key": "properties.provisioningAction", "type": "str"}, + "status": {"key": "properties.status", "type": "str"}, "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "status": {"key": "properties.status", "type": "MarketplaceGalleryImageStatus"}, } def __init__( self, *, - location: str, - tags: Optional[Dict[str, str]] = None, - extended_location: Optional["_models.ExtendedLocation"] = None, - container_id: Optional[str] = None, - os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, - cloud_init_data_source: Optional[Union[str, "_models.CloudInitDataSource"]] = None, - hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, - identifier: Optional["_models.GalleryImageIdentifier"] = None, - version: Optional["_models.GalleryImageVersion"] = None, + credentials: Optional["_models.GuestCredential"] = None, + provisioning_action: Optional[Union[str, "_models.ProvisioningAction"]] = None, **kwargs: Any ) -> None: """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword location: The geo-location where the resource lives. Required. + :keyword credentials: Username / Password Credentials to provision guest agent. + :paramtype credentials: ~azure.mgmt.azurestackhci.models.GuestCredential + :keyword provisioning_action: The guest agent provisioning action. Known values are: "install", + "uninstall", and "repair". + :paramtype provisioning_action: str or ~azure.mgmt.azurestackhci.models.ProvisioningAction + """ + super().__init__(**kwargs) + self.credentials = credentials + self.provisioning_action = provisioning_action + self.status = None + self.provisioning_state = None + + +class GuestAgentInstallStatus(_serialization.Model): + """Defines the status of a guest agent installation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar vm_uuid: Specifies the VM's unique SMBIOS ID. + :vartype vm_uuid: str + :ivar status: The installation status of the hybrid machine agent installation. Known values + are: "Succeeded", "InProgress", and "Failed". + :vartype status: str or ~azure.mgmt.azurestackhci.models.StatusTypes + :ivar last_status_change: The time of the last status change. + :vartype last_status_change: ~datetime.datetime + :ivar agent_version: The hybrid machine agent full version. + :vartype agent_version: str + :ivar error_details: Details about the error state. + :vartype error_details: list[~azure.mgmt.azurestackhci.models.ErrorDetail] + """ + + _validation = { + "vm_uuid": {"readonly": True}, + "status": {"readonly": True}, + "last_status_change": {"readonly": True}, + "agent_version": {"readonly": True}, + "error_details": {"readonly": True}, + } + + _attribute_map = { + "vm_uuid": {"key": "vmUuid", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "last_status_change": {"key": "lastStatusChange", "type": "iso-8601"}, + "agent_version": {"key": "agentVersion", "type": "str"}, + "error_details": {"key": "errorDetails", "type": "[ErrorDetail]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.vm_uuid = None + self.status = None + self.last_status_change = None + self.agent_version = None + self.error_details = None + + +class GuestAgentList(_serialization.Model): + """List of GuestAgent. + + All required parameters must be populated in order to send to server. + + :ivar next_link: Url to follow for getting next page of GuestAgent. + :vartype next_link: str + :ivar value: Array of GuestAgent. Required. + :vartype value: list[~azure.mgmt.azurestackhci.models.GuestAgent] + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "next_link": {"key": "nextLink", "type": "str"}, + "value": {"key": "value", "type": "[GuestAgent]"}, + } + + def __init__(self, *, value: List["_models.GuestAgent"], next_link: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword next_link: Url to follow for getting next page of GuestAgent. + :paramtype next_link: str + :keyword value: Array of GuestAgent. Required. + :paramtype value: list[~azure.mgmt.azurestackhci.models.GuestAgent] + """ + super().__init__(**kwargs) + self.next_link = next_link + self.value = value + + +class GuestCredential(_serialization.Model): + """Username / Password Credentials to connect to guest. + + :ivar username: The username to connect with the guest. + :vartype username: str + :ivar password: The password to connect with the guest. + :vartype password: str + """ + + _attribute_map = { + "username": {"key": "username", "type": "str"}, + "password": {"key": "password", "type": "str"}, + } + + def __init__(self, *, username: Optional[str] = None, password: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword username: The username to connect with the guest. + :paramtype username: str + :keyword password: The password to connect with the guest. + :paramtype password: str + """ + super().__init__(**kwargs) + self.username = username + self.password = password + + +class HardwareProfileUpdate(_serialization.Model): + """HardwareProfile - Specifies the hardware settings for the virtual machine instance. + + :ivar vm_size: Known values are: "Default", "Standard_A2_v2", "Standard_A4_v2", + "Standard_D2s_v3", "Standard_D4s_v3", "Standard_D8s_v3", "Standard_D16s_v3", + "Standard_D32s_v3", "Standard_DS2_v2", "Standard_DS3_v2", "Standard_DS4_v2", "Standard_DS5_v2", + "Standard_DS13_v2", "Standard_K8S_v1", "Standard_K8S2_v1", "Standard_K8S3_v1", + "Standard_K8S4_v1", "Standard_NK6", "Standard_NK12", "Standard_NV6", "Standard_NV12", + "Standard_K8S5_v1", and "Custom". + :vartype vm_size: str or ~azure.mgmt.azurestackhci.models.VmSizeEnum + :ivar processors: number of processors for the virtual machine instance. + :vartype processors: int + :ivar memory_mb: RAM in MB for the virtual machine instance. + :vartype memory_mb: int + """ + + _attribute_map = { + "vm_size": {"key": "vmSize", "type": "str"}, + "processors": {"key": "processors", "type": "int"}, + "memory_mb": {"key": "memoryMB", "type": "int"}, + } + + def __init__( + self, + *, + vm_size: Optional[Union[str, "_models.VmSizeEnum"]] = None, + processors: Optional[int] = None, + memory_mb: Optional[int] = None, + **kwargs: Any + ) -> None: + """ + :keyword vm_size: Known values are: "Default", "Standard_A2_v2", "Standard_A4_v2", + "Standard_D2s_v3", "Standard_D4s_v3", "Standard_D8s_v3", "Standard_D16s_v3", + "Standard_D32s_v3", "Standard_DS2_v2", "Standard_DS3_v2", "Standard_DS4_v2", "Standard_DS5_v2", + "Standard_DS13_v2", "Standard_K8S_v1", "Standard_K8S2_v1", "Standard_K8S3_v1", + "Standard_K8S4_v1", "Standard_NK6", "Standard_NK12", "Standard_NV6", "Standard_NV12", + "Standard_K8S5_v1", and "Custom". + :paramtype vm_size: str or ~azure.mgmt.azurestackhci.models.VmSizeEnum + :keyword processors: number of processors for the virtual machine instance. + :paramtype processors: int + :keyword memory_mb: RAM in MB for the virtual machine instance. + :paramtype memory_mb: int + """ + super().__init__(**kwargs) + self.vm_size = vm_size + self.processors = processors + self.memory_mb = memory_mb + + +class HostNetwork(_serialization.Model): + """The HostNetwork of a cluster. + + :ivar intents: The network intents assigned to the network reference pattern used for the + deployment. Each intent will define its own name, traffic type, adapter names, and overrides as + recommended by your OEM. + :vartype intents: list[~azure.mgmt.azurestackhci.models.Intents] + :ivar storage_networks: List of StorageNetworks config to deploy AzureStackHCI Cluster. + :vartype storage_networks: list[~azure.mgmt.azurestackhci.models.StorageNetworks] + :ivar storage_connectivity_switchless: Defines how the storage adapters between nodes are + connected either switch or switch less.. + :vartype storage_connectivity_switchless: bool + :ivar enable_storage_auto_ip: Optional parameter required only for 3 Nodes Switchless + deployments. This allows users to specify IPs and Mask for Storage NICs when Network ATC is not + assigning the IPs for storage automatically. + :vartype enable_storage_auto_ip: bool + """ + + _attribute_map = { + "intents": {"key": "intents", "type": "[Intents]"}, + "storage_networks": {"key": "storageNetworks", "type": "[StorageNetworks]"}, + "storage_connectivity_switchless": {"key": "storageConnectivitySwitchless", "type": "bool"}, + "enable_storage_auto_ip": {"key": "enableStorageAutoIp", "type": "bool"}, + } + + def __init__( + self, + *, + intents: Optional[List["_models.Intents"]] = None, + storage_networks: Optional[List["_models.StorageNetworks"]] = None, + storage_connectivity_switchless: bool = False, + enable_storage_auto_ip: bool = False, + **kwargs: Any + ) -> None: + """ + :keyword intents: The network intents assigned to the network reference pattern used for the + deployment. Each intent will define its own name, traffic type, adapter names, and overrides as + recommended by your OEM. + :paramtype intents: list[~azure.mgmt.azurestackhci.models.Intents] + :keyword storage_networks: List of StorageNetworks config to deploy AzureStackHCI Cluster. + :paramtype storage_networks: list[~azure.mgmt.azurestackhci.models.StorageNetworks] + :keyword storage_connectivity_switchless: Defines how the storage adapters between nodes are + connected either switch or switch less.. + :paramtype storage_connectivity_switchless: bool + :keyword enable_storage_auto_ip: Optional parameter required only for 3 Nodes Switchless + deployments. This allows users to specify IPs and Mask for Storage NICs when Network ATC is not + assigning the IPs for storage automatically. + :paramtype enable_storage_auto_ip: bool + """ + super().__init__(**kwargs) + self.intents = intents + self.storage_networks = storage_networks + self.storage_connectivity_switchless = storage_connectivity_switchless + self.enable_storage_auto_ip = enable_storage_auto_ip + + +class HttpProxyConfiguration(_serialization.Model): + """HTTP Proxy configuration for the VM. + + :ivar http_proxy: The HTTP proxy server endpoint to use. + :vartype http_proxy: str + :ivar https_proxy: The HTTPS proxy server endpoint to use. + :vartype https_proxy: str + :ivar no_proxy: The endpoints that should not go through proxy. + :vartype no_proxy: list[str] + :ivar trusted_ca: Alternative CA cert to use for connecting to proxy servers. + :vartype trusted_ca: str + """ + + _attribute_map = { + "http_proxy": {"key": "httpProxy", "type": "str"}, + "https_proxy": {"key": "httpsProxy", "type": "str"}, + "no_proxy": {"key": "noProxy", "type": "[str]"}, + "trusted_ca": {"key": "trustedCa", "type": "str"}, + } + + def __init__( + self, + *, + http_proxy: Optional[str] = None, + https_proxy: Optional[str] = None, + no_proxy: Optional[List[str]] = None, + trusted_ca: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword http_proxy: The HTTP proxy server endpoint to use. + :paramtype http_proxy: str + :keyword https_proxy: The HTTPS proxy server endpoint to use. + :paramtype https_proxy: str + :keyword no_proxy: The endpoints that should not go through proxy. + :paramtype no_proxy: list[str] + :keyword trusted_ca: Alternative CA cert to use for connecting to proxy servers. + :paramtype trusted_ca: str + """ + super().__init__(**kwargs) + self.http_proxy = http_proxy + self.https_proxy = https_proxy + self.no_proxy = no_proxy + self.trusted_ca = trusted_ca + + +class HybridIdentityMetadata(ProxyResource): + """Defines the HybridIdentityMetadata. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.azurestackhci.models.SystemData + :ivar resource_uid: The unique identifier for the resource. + :vartype resource_uid: str + :ivar public_key: The Public Key. + :vartype public_key: str + :ivar identity: Identity for the resource. + :vartype identity: ~azure.mgmt.azurestackhci.models.Identity + :ivar provisioning_state: The provisioning state. + :vartype provisioning_state: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "identity": {"readonly": True}, + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "resource_uid": {"key": "properties.resourceUid", "type": "str"}, + "public_key": {"key": "properties.publicKey", "type": "str"}, + "identity": {"key": "properties.identity", "type": "Identity"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + } + + def __init__(self, *, resource_uid: Optional[str] = None, public_key: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword resource_uid: The unique identifier for the resource. + :paramtype resource_uid: str + :keyword public_key: The Public Key. + :paramtype public_key: str + """ + super().__init__(**kwargs) + self.resource_uid = resource_uid + self.public_key = public_key + self.identity = None + self.provisioning_state = None + + +class HybridIdentityMetadataList(_serialization.Model): + """List of HybridIdentityMetadata. + + All required parameters must be populated in order to send to server. + + :ivar next_link: Url to follow for getting next page of HybridIdentityMetadata. + :vartype next_link: str + :ivar value: Array of HybridIdentityMetadata. Required. + :vartype value: list[~azure.mgmt.azurestackhci.models.HybridIdentityMetadata] + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "next_link": {"key": "nextLink", "type": "str"}, + "value": {"key": "value", "type": "[HybridIdentityMetadata]"}, + } + + def __init__( + self, *, value: List["_models.HybridIdentityMetadata"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword next_link: Url to follow for getting next page of HybridIdentityMetadata. + :paramtype next_link: str + :keyword value: Array of HybridIdentityMetadata. Required. + :paramtype value: list[~azure.mgmt.azurestackhci.models.HybridIdentityMetadata] + """ + super().__init__(**kwargs) + self.next_link = next_link + self.value = value + + +class Identity(_serialization.Model): + """Identity for the resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal ID of resource identity. + :vartype principal_id: str + :ivar tenant_id: The tenant ID of resource. + :vartype tenant_id: str + :ivar type: The identity type. Default value is "SystemAssigned". + :vartype type: str + """ + + _validation = { + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, + } + + _attribute_map = { + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, *, type: Optional[Literal["SystemAssigned"]] = None, **kwargs: Any) -> None: + """ + :keyword type: The identity type. Default value is "SystemAssigned". + :paramtype type: str + """ + super().__init__(**kwargs) + self.principal_id = None + self.tenant_id = None + self.type = type + + +class InfrastructureNetwork(_serialization.Model): + """The InfrastructureNetwork of a AzureStackHCI Cluster. + + :ivar subnet_mask: Subnet mask that matches the provided IP address space. + :vartype subnet_mask: str + :ivar gateway: Default gateway that should be used for the provided IP address space. + :vartype gateway: str + :ivar ip_pools: Range of IP addresses from which addresses are allocated for nodes within a + subnet. + :vartype ip_pools: list[~azure.mgmt.azurestackhci.models.IpPools] + :ivar dns_servers: IPv4 address of the DNS servers in your environment. + :vartype dns_servers: list[str] + :ivar use_dhcp: Allows customers to use DHCP for Hosts and Cluster IPs. If not declared, the + deployment will default to static IPs. When true, GW and DNS servers are not required. + :vartype use_dhcp: bool + """ + + _attribute_map = { + "subnet_mask": {"key": "subnetMask", "type": "str"}, + "gateway": {"key": "gateway", "type": "str"}, + "ip_pools": {"key": "ipPools", "type": "[IpPools]"}, + "dns_servers": {"key": "dnsServers", "type": "[str]"}, + "use_dhcp": {"key": "useDhcp", "type": "bool"}, + } + + def __init__( + self, + *, + subnet_mask: Optional[str] = None, + gateway: Optional[str] = None, + ip_pools: Optional[List["_models.IpPools"]] = None, + dns_servers: Optional[List[str]] = None, + use_dhcp: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword subnet_mask: Subnet mask that matches the provided IP address space. + :paramtype subnet_mask: str + :keyword gateway: Default gateway that should be used for the provided IP address space. + :paramtype gateway: str + :keyword ip_pools: Range of IP addresses from which addresses are allocated for nodes within a + subnet. + :paramtype ip_pools: list[~azure.mgmt.azurestackhci.models.IpPools] + :keyword dns_servers: IPv4 address of the DNS servers in your environment. + :paramtype dns_servers: list[str] + :keyword use_dhcp: Allows customers to use DHCP for Hosts and Cluster IPs. If not declared, the + deployment will default to static IPs. When true, GW and DNS servers are not required. + :paramtype use_dhcp: bool + """ + super().__init__(**kwargs) + self.subnet_mask = subnet_mask + self.gateway = gateway + self.ip_pools = ip_pools + self.dns_servers = dns_servers + self.use_dhcp = use_dhcp + + +class InstanceViewStatus(_serialization.Model): + """Instance view status. + + :ivar code: The status code. + :vartype code: str + :ivar level: The level code. Known values are: "Info", "Warning", and "Error". + :vartype level: str or ~azure.mgmt.azurestackhci.models.StatusLevelTypes + :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 + """ + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "level": {"key": "level", "type": "str"}, + "display_status": {"key": "displayStatus", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "time": {"key": "time", "type": "iso-8601"}, + } + + def __init__( + self, + *, + code: Optional[str] = None, + level: Optional[Union[str, "_models.StatusLevelTypes"]] = None, + display_status: Optional[str] = None, + message: Optional[str] = None, + time: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :keyword code: The status code. + :paramtype code: str + :keyword level: The level code. Known values are: "Info", "Warning", and "Error". + :paramtype level: str or ~azure.mgmt.azurestackhci.models.StatusLevelTypes + :keyword display_status: The short localizable label for the status. + :paramtype display_status: str + :keyword message: The detailed status message, including for alerts and error messages. + :paramtype message: str + :keyword time: The time of the status. + :paramtype time: ~datetime.datetime + """ + super().__init__(**kwargs) + self.code = code + self.level = level + self.display_status = display_status + self.message = message + self.time = time + + +class Intents(_serialization.Model): + """The Intents of a cluster. + + :ivar name: Name of the network intent you wish to create. + :vartype name: str + :ivar traffic_type: List of network traffic types. Only allowed values are 'Compute', + 'Storage', 'Management'. + :vartype traffic_type: list[str] + :ivar adapter: Array of network interfaces used for the network intent. + :vartype adapter: list[str] + :ivar override_virtual_switch_configuration: This parameter should only be modified based on + your OEM guidance. Do not modify this parameter without OEM validation. + :vartype override_virtual_switch_configuration: bool + :ivar virtual_switch_configuration_overrides: Set virtualSwitch ConfigurationOverrides for + cluster. + :vartype virtual_switch_configuration_overrides: + ~azure.mgmt.azurestackhci.models.VirtualSwitchConfigurationOverrides + :ivar override_qos_policy: This parameter should only be modified based on your OEM guidance. + Do not modify this parameter without OEM validation. + :vartype override_qos_policy: bool + :ivar qos_policy_overrides: Set QoS PolicyOverrides for cluster. + :vartype qos_policy_overrides: ~azure.mgmt.azurestackhci.models.QosPolicyOverrides + :ivar override_adapter_property: This parameter should only be modified based on your OEM + guidance. Do not modify this parameter without OEM validation. + :vartype override_adapter_property: bool + :ivar adapter_property_overrides: Set Adapter PropertyOverrides for cluster. + :vartype adapter_property_overrides: ~azure.mgmt.azurestackhci.models.AdapterPropertyOverrides + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "traffic_type": {"key": "trafficType", "type": "[str]"}, + "adapter": {"key": "adapter", "type": "[str]"}, + "override_virtual_switch_configuration": {"key": "overrideVirtualSwitchConfiguration", "type": "bool"}, + "virtual_switch_configuration_overrides": { + "key": "virtualSwitchConfigurationOverrides", + "type": "VirtualSwitchConfigurationOverrides", + }, + "override_qos_policy": {"key": "overrideQosPolicy", "type": "bool"}, + "qos_policy_overrides": {"key": "qosPolicyOverrides", "type": "QosPolicyOverrides"}, + "override_adapter_property": {"key": "overrideAdapterProperty", "type": "bool"}, + "adapter_property_overrides": {"key": "adapterPropertyOverrides", "type": "AdapterPropertyOverrides"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + traffic_type: Optional[List[str]] = None, + adapter: Optional[List[str]] = None, + override_virtual_switch_configuration: bool = False, + virtual_switch_configuration_overrides: Optional["_models.VirtualSwitchConfigurationOverrides"] = None, + override_qos_policy: bool = False, + qos_policy_overrides: Optional["_models.QosPolicyOverrides"] = None, + override_adapter_property: bool = False, + adapter_property_overrides: Optional["_models.AdapterPropertyOverrides"] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: Name of the network intent you wish to create. + :paramtype name: str + :keyword traffic_type: List of network traffic types. Only allowed values are 'Compute', + 'Storage', 'Management'. + :paramtype traffic_type: list[str] + :keyword adapter: Array of network interfaces used for the network intent. + :paramtype adapter: list[str] + :keyword override_virtual_switch_configuration: This parameter should only be modified based on + your OEM guidance. Do not modify this parameter without OEM validation. + :paramtype override_virtual_switch_configuration: bool + :keyword virtual_switch_configuration_overrides: Set virtualSwitch ConfigurationOverrides for + cluster. + :paramtype virtual_switch_configuration_overrides: + ~azure.mgmt.azurestackhci.models.VirtualSwitchConfigurationOverrides + :keyword override_qos_policy: This parameter should only be modified based on your OEM + guidance. Do not modify this parameter without OEM validation. + :paramtype override_qos_policy: bool + :keyword qos_policy_overrides: Set QoS PolicyOverrides for cluster. + :paramtype qos_policy_overrides: ~azure.mgmt.azurestackhci.models.QosPolicyOverrides + :keyword override_adapter_property: This parameter should only be modified based on your OEM + guidance. Do not modify this parameter without OEM validation. + :paramtype override_adapter_property: bool + :keyword adapter_property_overrides: Set Adapter PropertyOverrides for cluster. + :paramtype adapter_property_overrides: + ~azure.mgmt.azurestackhci.models.AdapterPropertyOverrides + """ + super().__init__(**kwargs) + self.name = name + self.traffic_type = traffic_type + self.adapter = adapter + self.override_virtual_switch_configuration = override_virtual_switch_configuration + self.virtual_switch_configuration_overrides = virtual_switch_configuration_overrides + self.override_qos_policy = override_qos_policy + self.qos_policy_overrides = qos_policy_overrides + self.override_adapter_property = override_adapter_property + self.adapter_property_overrides = adapter_property_overrides + + +class InterfaceDNSSettings(_serialization.Model): + """InterfaceDNSSettings. + + :ivar dns_servers: List of DNS server IP Addresses for the interface. + :vartype dns_servers: list[str] + """ + + _attribute_map = { + "dns_servers": {"key": "dnsServers", "type": "[str]"}, + } + + def __init__(self, *, dns_servers: Optional[List[str]] = None, **kwargs: Any) -> None: + """ + :keyword dns_servers: List of DNS server IP Addresses for the interface. + :paramtype dns_servers: list[str] + """ + super().__init__(**kwargs) + self.dns_servers = dns_servers + + +class IPConfiguration(_serialization.Model): + """InterfaceIPConfiguration iPConfiguration in a network interface. + + :ivar name: Name - The name of the resource that is unique within a resource group. This name + can be used to access the resource. + :vartype name: str + :ivar properties: InterfaceIPConfigurationPropertiesFormat properties of IP configuration. + :vartype properties: ~azure.mgmt.azurestackhci.models.IPConfigurationProperties + """ + + _validation = { + "name": {"pattern": r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-._a-zA-Z0-9]{0,78}[_a-zA-Z0-9]$"}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "properties": {"key": "properties", "type": "IPConfigurationProperties"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + properties: Optional["_models.IPConfigurationProperties"] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: Name - The name of the resource that is unique within a resource group. This + name can be used to access the resource. + :paramtype name: str + :keyword properties: InterfaceIPConfigurationPropertiesFormat properties of IP configuration. + :paramtype properties: ~azure.mgmt.azurestackhci.models.IPConfigurationProperties + """ + super().__init__(**kwargs) + self.name = name + self.properties = properties + + +class IPConfigurationProperties(_serialization.Model): + """InterfaceIPConfigurationPropertiesFormat properties of IP configuration. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar gateway: Gateway for network interface. + :vartype gateway: str + :ivar prefix_length: prefixLength for network interface. + :vartype prefix_length: str + :ivar private_ip_address: PrivateIPAddress - Private IP address of the IP configuration. + :vartype private_ip_address: str + :ivar subnet: Subnet - Name of Subnet bound to the IP configuration. + :vartype subnet: ~azure.mgmt.azurestackhci.models.IPConfigurationPropertiesSubnet + """ + + _validation = { + "gateway": {"readonly": True}, + "prefix_length": {"readonly": True}, + } + + _attribute_map = { + "gateway": {"key": "gateway", "type": "str"}, + "prefix_length": {"key": "prefixLength", "type": "str"}, + "private_ip_address": {"key": "privateIPAddress", "type": "str"}, + "subnet": {"key": "subnet", "type": "IPConfigurationPropertiesSubnet"}, + } + + def __init__( + self, + *, + private_ip_address: Optional[str] = None, + subnet: Optional["_models.IPConfigurationPropertiesSubnet"] = None, + **kwargs: Any + ) -> None: + """ + :keyword private_ip_address: PrivateIPAddress - Private IP address of the IP configuration. + :paramtype private_ip_address: str + :keyword subnet: Subnet - Name of Subnet bound to the IP configuration. + :paramtype subnet: ~azure.mgmt.azurestackhci.models.IPConfigurationPropertiesSubnet + """ + super().__init__(**kwargs) + self.gateway = None + self.prefix_length = None + self.private_ip_address = private_ip_address + self.subnet = subnet + + +class IPConfigurationPropertiesSubnet(_serialization.Model): + """Subnet - Name of Subnet bound to the IP configuration. + + :ivar id: ID - The ARM resource id in the form of + /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/... + :vartype id: str + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + } + + def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin + """ + :keyword id: ID - The ARM resource id in the form of + /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/... + :paramtype id: str + """ + super().__init__(**kwargs) + self.id = id + + +class IPPool(_serialization.Model): + """IPPool. + + :ivar name: Name of the IP-Pool. + :vartype name: str + :ivar ip_pool_type: Type of the IP Pool [vm, vippool]. Known values are: "vm" and "vippool". + :vartype ip_pool_type: str or ~azure.mgmt.azurestackhci.models.IPPoolTypeEnum + :ivar start: Start of the IP address pool. + :vartype start: str + :ivar end: End of the IP address pool. + :vartype end: str + :ivar info: + :vartype info: ~azure.mgmt.azurestackhci.models.IPPoolInfo + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "ip_pool_type": {"key": "ipPoolType", "type": "str"}, + "start": {"key": "start", "type": "str"}, + "end": {"key": "end", "type": "str"}, + "info": {"key": "info", "type": "IPPoolInfo"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + ip_pool_type: Optional[Union[str, "_models.IPPoolTypeEnum"]] = None, + start: Optional[str] = None, + end: Optional[str] = None, + info: Optional["_models.IPPoolInfo"] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: Name of the IP-Pool. + :paramtype name: str + :keyword ip_pool_type: Type of the IP Pool [vm, vippool]. Known values are: "vm" and "vippool". + :paramtype ip_pool_type: str or ~azure.mgmt.azurestackhci.models.IPPoolTypeEnum + :keyword start: Start of the IP address pool. + :paramtype start: str + :keyword end: End of the IP address pool. + :paramtype end: str + :keyword info: + :paramtype info: ~azure.mgmt.azurestackhci.models.IPPoolInfo + """ + super().__init__(**kwargs) + self.name = name + self.ip_pool_type = ip_pool_type + self.start = start + self.end = end + self.info = info + + +class IPPoolInfo(_serialization.Model): + """IPPoolInfo. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar used: Number of IP addresses allocated from the IP Pool. + :vartype used: str + :ivar available: Number of IP addresses available in the IP Pool. + :vartype available: str + """ + + _validation = { + "used": {"readonly": True}, + "available": {"readonly": True}, + } + + _attribute_map = { + "used": {"key": "used", "type": "str"}, + "available": {"key": "available", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.used = None + self.available = None + + +class IpPools(_serialization.Model): + """The dnsServers of a device. + + :ivar starting_address: Starting IP address for the management network. A minimum of six free, + contiguous IPv4 addresses (excluding your host IPs) are needed for infrastructure services such + as clustering. + :vartype starting_address: str + :ivar ending_address: Ending IP address for the management network. A minimum of six free, + contiguous IPv4 addresses (excluding your host IPs) are needed for infrastructure services such + as clustering. + :vartype ending_address: str + """ + + _attribute_map = { + "starting_address": {"key": "startingAddress", "type": "str"}, + "ending_address": {"key": "endingAddress", "type": "str"}, + } + + def __init__( + self, *, starting_address: Optional[str] = None, ending_address: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword starting_address: Starting IP address for the management network. A minimum of six + free, contiguous IPv4 addresses (excluding your host IPs) are needed for infrastructure + services such as clustering. + :paramtype starting_address: str + :keyword ending_address: Ending IP address for the management network. A minimum of six free, + contiguous IPv4 addresses (excluding your host IPs) are needed for infrastructure services such + as clustering. + :paramtype ending_address: str + """ + super().__init__(**kwargs) + self.starting_address = starting_address + self.ending_address = ending_address + + +class IsolatedVmAttestationConfiguration(_serialization.Model): + """Attestation configurations for isolated VM (e.g. TVM, CVM) of the cluster. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar attestation_resource_id: Fully qualified Azure resource id of the Microsoft Azure + attestation resource associated with this cluster. + :vartype attestation_resource_id: str + :ivar relying_party_service_endpoint: Region specific endpoint for relying party service. + :vartype relying_party_service_endpoint: str + :ivar attestation_service_endpoint: Region specific endpoint for Microsoft Azure Attestation + service for the cluster. + :vartype attestation_service_endpoint: str + """ + + _validation = { + "attestation_resource_id": {"readonly": True}, + "relying_party_service_endpoint": {"readonly": True}, + "attestation_service_endpoint": {"readonly": True}, + } + + _attribute_map = { + "attestation_resource_id": {"key": "attestationResourceId", "type": "str"}, + "relying_party_service_endpoint": {"key": "relyingPartyServiceEndpoint", "type": "str"}, + "attestation_service_endpoint": {"key": "attestationServiceEndpoint", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.attestation_resource_id = None + self.relying_party_service_endpoint = None + self.attestation_service_endpoint = None + + +class LogicalNetworkPropertiesDhcpOptions(_serialization.Model): + """DhcpOptions contains an array of DNS servers available to VMs deployed in the logical network. + Standard DHCP option for a subnet overrides logical network DHCP options. + + :ivar dns_servers: The list of DNS servers IP addresses. + :vartype dns_servers: list[str] + """ + + _attribute_map = { + "dns_servers": {"key": "dnsServers", "type": "[str]"}, + } + + def __init__(self, *, dns_servers: Optional[List[str]] = None, **kwargs: Any) -> None: + """ + :keyword dns_servers: The list of DNS servers IP addresses. + :paramtype dns_servers: list[str] + """ + super().__init__(**kwargs) + self.dns_servers = dns_servers + + +class LogicalNetworks(TrackedResource): # pylint: disable=too-many-instance-attributes + """The logical network resource 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 server. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.azurestackhci.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar extended_location: The extendedLocation of the resource. + :vartype extended_location: ~azure.mgmt.azurestackhci.models.ExtendedLocation + :ivar dhcp_options: DhcpOptions contains an array of DNS servers available to VMs deployed in + the logical network. Standard DHCP option for a subnet overrides logical network DHCP options. + :vartype dhcp_options: ~azure.mgmt.azurestackhci.models.LogicalNetworkPropertiesDhcpOptions + :ivar subnets: Subnet - list of subnets under the logical network. + :vartype subnets: list[~azure.mgmt.azurestackhci.models.Subnet] + :ivar provisioning_state: Provisioning state of the logical network. Known values are: + "Succeeded", "Failed", "InProgress", "Accepted", "Deleting", and "Canceled". + :vartype provisioning_state: str or ~azure.mgmt.azurestackhci.models.ProvisioningStateEnum + :ivar vm_switch_name: name of the network switch to be used for VMs. + :vartype vm_switch_name: str + :ivar status: The observed state of logical networks. + :vartype status: ~azure.mgmt.azurestackhci.models.LogicalNetworkStatus + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"}, + "dhcp_options": {"key": "properties.dhcpOptions", "type": "LogicalNetworkPropertiesDhcpOptions"}, + "subnets": {"key": "properties.subnets", "type": "[Subnet]"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "vm_switch_name": {"key": "properties.vmSwitchName", "type": "str"}, + "status": {"key": "properties.status", "type": "LogicalNetworkStatus"}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, + dhcp_options: Optional["_models.LogicalNetworkPropertiesDhcpOptions"] = None, + subnets: Optional[List["_models.Subnet"]] = None, + vm_switch_name: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + :keyword extended_location: The extendedLocation of the resource. + :paramtype extended_location: ~azure.mgmt.azurestackhci.models.ExtendedLocation + :keyword dhcp_options: DhcpOptions contains an array of DNS servers available to VMs deployed + in the logical network. Standard DHCP option for a subnet overrides logical network DHCP + options. + :paramtype dhcp_options: ~azure.mgmt.azurestackhci.models.LogicalNetworkPropertiesDhcpOptions + :keyword subnets: Subnet - list of subnets under the logical network. + :paramtype subnets: list[~azure.mgmt.azurestackhci.models.Subnet] + :keyword vm_switch_name: name of the network switch to be used for VMs. + :paramtype vm_switch_name: str + """ + super().__init__(tags=tags, location=location, **kwargs) + self.extended_location = extended_location + self.dhcp_options = dhcp_options + self.subnets = subnets + self.provisioning_state = None + self.vm_switch_name = vm_switch_name + self.status = None + + +class LogicalNetworksListResult(_serialization.Model): + """LogicalNetworksListResult. + + :ivar value: + :vartype value: list[~azure.mgmt.azurestackhci.models.LogicalNetworks] + :ivar next_link: + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[LogicalNetworks]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: Optional[List["_models.LogicalNetworks"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: + :paramtype value: list[~azure.mgmt.azurestackhci.models.LogicalNetworks] + :keyword next_link: + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class LogicalNetworkStatus(_serialization.Model): + """The observed state of logical networks. + + :ivar error_code: LogicalNetwork provisioning error code. + :vartype error_code: str + :ivar error_message: Descriptive error message. + :vartype error_message: str + :ivar provisioning_status: + :vartype provisioning_status: + ~azure.mgmt.azurestackhci.models.LogicalNetworkStatusProvisioningStatus + """ + + _attribute_map = { + "error_code": {"key": "errorCode", "type": "str"}, + "error_message": {"key": "errorMessage", "type": "str"}, + "provisioning_status": {"key": "provisioningStatus", "type": "LogicalNetworkStatusProvisioningStatus"}, + } + + def __init__( + self, + *, + error_code: Optional[str] = None, + error_message: Optional[str] = None, + provisioning_status: Optional["_models.LogicalNetworkStatusProvisioningStatus"] = None, + **kwargs: Any + ) -> None: + """ + :keyword error_code: LogicalNetwork provisioning error code. + :paramtype error_code: str + :keyword error_message: Descriptive error message. + :paramtype error_message: str + :keyword provisioning_status: + :paramtype provisioning_status: + ~azure.mgmt.azurestackhci.models.LogicalNetworkStatusProvisioningStatus + """ + super().__init__(**kwargs) + self.error_code = error_code + self.error_message = error_message + self.provisioning_status = provisioning_status + + +class LogicalNetworkStatusProvisioningStatus(_serialization.Model): + """LogicalNetworkStatusProvisioningStatus. + + :ivar operation_id: The ID of the operation performed on the logical network. + :vartype operation_id: str + :ivar status: The status of the operation performed on the logical network [Succeeded, Failed, + InProgress]. Known values are: "NotYetRegistered", "ConnectedRecently", "NotConnectedRecently", + "Disconnected", "Error", "NotSpecified", "ValidationInProgress", "ValidationSuccess", + "ValidationFailed", "DeploymentInProgress", "DeploymentFailed", "DeploymentSuccess", + "Succeeded", "Failed", and "InProgress". + :vartype status: str or ~azure.mgmt.azurestackhci.models.Status + """ + + _attribute_map = { + "operation_id": {"key": "operationId", "type": "str"}, + "status": {"key": "status", "type": "str"}, + } + + def __init__( + self, + *, + operation_id: Optional[str] = None, + status: Optional[Union[str, "_models.Status"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword operation_id: The ID of the operation performed on the logical network. + :paramtype operation_id: str + :keyword status: The status of the operation performed on the logical network [Succeeded, + Failed, InProgress]. Known values are: "NotYetRegistered", "ConnectedRecently", + "NotConnectedRecently", "Disconnected", "Error", "NotSpecified", "ValidationInProgress", + "ValidationSuccess", "ValidationFailed", "DeploymentInProgress", "DeploymentFailed", + "DeploymentSuccess", "Succeeded", "Failed", and "InProgress". + :paramtype status: str or ~azure.mgmt.azurestackhci.models.Status + """ + super().__init__(**kwargs) + self.operation_id = operation_id + self.status = status + + +class LogicalNetworksUpdateRequest(_serialization.Model): + """The logical network resource patch definition. + + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + } + + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.tags = tags + + +class MarketplaceGalleryImages(TrackedResource): # pylint: disable=too-many-instance-attributes + """The marketplace gallery image resource 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 server. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.azurestackhci.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar extended_location: The extendedLocation of the resource. + :vartype extended_location: ~azure.mgmt.azurestackhci.models.ExtendedLocation + :ivar container_id: Storage ContainerID of the storage container to be used for marketplace + gallery image. + :vartype container_id: str + :ivar os_type: Operating system type that the gallery image uses [Windows, Linux]. Known values + are: "Windows" and "Linux". + :vartype os_type: str or ~azure.mgmt.azurestackhci.models.OperatingSystemTypes + :ivar cloud_init_data_source: Datasource for the gallery image when provisioning with + cloud-init [NoCloud, Azure]. Known values are: "NoCloud" and "Azure". + :vartype cloud_init_data_source: str or ~azure.mgmt.azurestackhci.models.CloudInitDataSource + :ivar hyper_v_generation: The hypervisor generation of the Virtual Machine [V1, V2]. Known + values are: "V1" and "V2". + :vartype hyper_v_generation: str or ~azure.mgmt.azurestackhci.models.HyperVGeneration + :ivar identifier: This is the gallery image definition identifier. + :vartype identifier: ~azure.mgmt.azurestackhci.models.GalleryImageIdentifier + :ivar version: Specifies information about the gallery image version that you want to create or + update. + :vartype version: ~azure.mgmt.azurestackhci.models.GalleryImageVersion + :ivar provisioning_state: Provisioning state of the marketplace gallery image. Known values + are: "Succeeded", "Failed", "InProgress", "Accepted", "Deleting", and "Canceled". + :vartype provisioning_state: str or ~azure.mgmt.azurestackhci.models.ProvisioningStateEnum + :ivar status: The observed state of marketplace gallery images. + :vartype status: ~azure.mgmt.azurestackhci.models.MarketplaceGalleryImageStatus + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"}, + "container_id": {"key": "properties.containerId", "type": "str"}, + "os_type": {"key": "properties.osType", "type": "str"}, + "cloud_init_data_source": {"key": "properties.cloudInitDataSource", "type": "str"}, + "hyper_v_generation": {"key": "properties.hyperVGeneration", "type": "str"}, + "identifier": {"key": "properties.identifier", "type": "GalleryImageIdentifier"}, + "version": {"key": "properties.version", "type": "GalleryImageVersion"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "status": {"key": "properties.status", "type": "MarketplaceGalleryImageStatus"}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, + container_id: Optional[str] = None, + os_type: Optional[Union[str, "_models.OperatingSystemTypes"]] = None, + cloud_init_data_source: Optional[Union[str, "_models.CloudInitDataSource"]] = None, + hyper_v_generation: Optional[Union[str, "_models.HyperVGeneration"]] = None, + identifier: Optional["_models.GalleryImageIdentifier"] = None, + version: Optional["_models.GalleryImageVersion"] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + :keyword extended_location: The extendedLocation of the resource. + :paramtype extended_location: ~azure.mgmt.azurestackhci.models.ExtendedLocation + :keyword container_id: Storage ContainerID of the storage container to be used for marketplace + gallery image. + :paramtype container_id: str + :keyword os_type: Operating system type that the gallery image uses [Windows, Linux]. Known + values are: "Windows" and "Linux". + :paramtype os_type: str or ~azure.mgmt.azurestackhci.models.OperatingSystemTypes + :keyword cloud_init_data_source: Datasource for the gallery image when provisioning with + cloud-init [NoCloud, Azure]. Known values are: "NoCloud" and "Azure". + :paramtype cloud_init_data_source: str or ~azure.mgmt.azurestackhci.models.CloudInitDataSource + :keyword hyper_v_generation: The hypervisor generation of the Virtual Machine [V1, V2]. Known + values are: "V1" and "V2". + :paramtype hyper_v_generation: str or ~azure.mgmt.azurestackhci.models.HyperVGeneration + :keyword identifier: This is the gallery image definition identifier. + :paramtype identifier: ~azure.mgmt.azurestackhci.models.GalleryImageIdentifier + :keyword version: Specifies information about the gallery image version that you want to create + or update. + :paramtype version: ~azure.mgmt.azurestackhci.models.GalleryImageVersion + """ + super().__init__(tags=tags, location=location, **kwargs) + self.extended_location = extended_location + self.container_id = container_id + self.os_type = os_type + self.cloud_init_data_source = cloud_init_data_source + self.hyper_v_generation = hyper_v_generation + self.identifier = identifier + self.version = version + self.provisioning_state = None + self.status = None + + +class MarketplaceGalleryImagesListResult(_serialization.Model): + """MarketplaceGalleryImagesListResult. + + :ivar value: + :vartype value: list[~azure.mgmt.azurestackhci.models.MarketplaceGalleryImages] + :ivar next_link: + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[MarketplaceGalleryImages]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.MarketplaceGalleryImages"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: + :paramtype value: list[~azure.mgmt.azurestackhci.models.MarketplaceGalleryImages] + :keyword next_link: + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class MarketplaceGalleryImageStatus(_serialization.Model): + """The observed state of marketplace gallery images. + + :ivar error_code: MarketplaceGalleryImage provisioning error code. + :vartype error_code: str + :ivar error_message: Descriptive error message. + :vartype error_message: str + :ivar provisioning_status: + :vartype provisioning_status: + ~azure.mgmt.azurestackhci.models.MarketplaceGalleryImageStatusProvisioningStatus + :ivar download_status: The download status of the gallery image. + :vartype download_status: + ~azure.mgmt.azurestackhci.models.MarketplaceGalleryImageStatusDownloadStatus + :ivar progress_percentage: The progress of the operation in percentage. + :vartype progress_percentage: int + """ + + _attribute_map = { + "error_code": {"key": "errorCode", "type": "str"}, + "error_message": {"key": "errorMessage", "type": "str"}, + "provisioning_status": {"key": "provisioningStatus", "type": "MarketplaceGalleryImageStatusProvisioningStatus"}, + "download_status": {"key": "downloadStatus", "type": "MarketplaceGalleryImageStatusDownloadStatus"}, + "progress_percentage": {"key": "progressPercentage", "type": "int"}, + } + + def __init__( + self, + *, + error_code: Optional[str] = None, + error_message: Optional[str] = None, + provisioning_status: Optional["_models.MarketplaceGalleryImageStatusProvisioningStatus"] = None, + download_status: Optional["_models.MarketplaceGalleryImageStatusDownloadStatus"] = None, + progress_percentage: Optional[int] = None, + **kwargs: Any + ) -> None: + """ + :keyword error_code: MarketplaceGalleryImage provisioning error code. + :paramtype error_code: str + :keyword error_message: Descriptive error message. + :paramtype error_message: str + :keyword provisioning_status: + :paramtype provisioning_status: + ~azure.mgmt.azurestackhci.models.MarketplaceGalleryImageStatusProvisioningStatus + :keyword download_status: The download status of the gallery image. + :paramtype download_status: + ~azure.mgmt.azurestackhci.models.MarketplaceGalleryImageStatusDownloadStatus + :keyword progress_percentage: The progress of the operation in percentage. + :paramtype progress_percentage: int + """ + super().__init__(**kwargs) + self.error_code = error_code + self.error_message = error_message + self.provisioning_status = provisioning_status + self.download_status = download_status + self.progress_percentage = progress_percentage + + +class MarketplaceGalleryImageStatusDownloadStatus(_serialization.Model): # pylint: disable=name-too-long + """The download status of the gallery image. + + :ivar download_size_in_mb: The downloaded sized of the image in MB. + :vartype download_size_in_mb: int + """ + + _attribute_map = { + "download_size_in_mb": {"key": "downloadSizeInMB", "type": "int"}, + } + + def __init__(self, *, download_size_in_mb: Optional[int] = None, **kwargs: Any) -> None: + """ + :keyword download_size_in_mb: The downloaded sized of the image in MB. + :paramtype download_size_in_mb: int + """ + super().__init__(**kwargs) + self.download_size_in_mb = download_size_in_mb + + +class MarketplaceGalleryImageStatusProvisioningStatus(_serialization.Model): # pylint: disable=name-too-long + """MarketplaceGalleryImageStatusProvisioningStatus. + + :ivar operation_id: The ID of the operation performed on the gallery image. + :vartype operation_id: str + :ivar status: The status of the operation performed on the gallery image [Succeeded, Failed, + InProgress]. Known values are: "NotYetRegistered", "ConnectedRecently", "NotConnectedRecently", + "Disconnected", "Error", "NotSpecified", "ValidationInProgress", "ValidationSuccess", + "ValidationFailed", "DeploymentInProgress", "DeploymentFailed", "DeploymentSuccess", + "Succeeded", "Failed", and "InProgress". + :vartype status: str or ~azure.mgmt.azurestackhci.models.Status + """ + + _attribute_map = { + "operation_id": {"key": "operationId", "type": "str"}, + "status": {"key": "status", "type": "str"}, + } + + def __init__( + self, + *, + operation_id: Optional[str] = None, + status: Optional[Union[str, "_models.Status"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword operation_id: The ID of the operation performed on the gallery image. + :paramtype operation_id: str + :keyword status: The status of the operation performed on the gallery image [Succeeded, Failed, + InProgress]. Known values are: "NotYetRegistered", "ConnectedRecently", "NotConnectedRecently", + "Disconnected", "Error", "NotSpecified", "ValidationInProgress", "ValidationSuccess", + "ValidationFailed", "DeploymentInProgress", "DeploymentFailed", "DeploymentSuccess", + "Succeeded", "Failed", and "InProgress". + :paramtype status: str or ~azure.mgmt.azurestackhci.models.Status + """ + super().__init__(**kwargs) + self.operation_id = operation_id + self.status = status + + +class MarketplaceGalleryImagesUpdateRequest(_serialization.Model): + """The marketplace gallery image resource patch definition. + + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + } + + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.tags = tags + + +class NetworkInterfaces(TrackedResource): # pylint: disable=too-many-instance-attributes + """The network interface resource 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 server. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.azurestackhci.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar extended_location: The extendedLocation of the resource. + :vartype extended_location: ~azure.mgmt.azurestackhci.models.ExtendedLocation + :ivar ip_configurations: IPConfigurations - A list of IPConfigurations of the network + interface. + :vartype ip_configurations: list[~azure.mgmt.azurestackhci.models.IPConfiguration] + :ivar mac_address: MacAddress - The MAC address of the network interface. + :vartype mac_address: str + :ivar dns_settings: DNS Settings for the interface. + :vartype dns_settings: ~azure.mgmt.azurestackhci.models.InterfaceDNSSettings + :ivar provisioning_state: Provisioning state of the network interface. Known values are: + "Succeeded", "Failed", "InProgress", "Accepted", "Deleting", and "Canceled". + :vartype provisioning_state: str or ~azure.mgmt.azurestackhci.models.ProvisioningStateEnum + :ivar status: The observed state of network interfaces. + :vartype status: ~azure.mgmt.azurestackhci.models.NetworkInterfaceStatus + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + "provisioning_state": {"readonly": True}, + "status": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"}, + "ip_configurations": {"key": "properties.ipConfigurations", "type": "[IPConfiguration]"}, + "mac_address": {"key": "properties.macAddress", "type": "str"}, + "dns_settings": {"key": "properties.dnsSettings", "type": "InterfaceDNSSettings"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "status": {"key": "properties.status", "type": "NetworkInterfaceStatus"}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, + ip_configurations: Optional[List["_models.IPConfiguration"]] = None, + mac_address: Optional[str] = None, + dns_settings: Optional["_models.InterfaceDNSSettings"] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str :keyword extended_location: The extendedLocation of the resource. :paramtype extended_location: ~azure.mgmt.azurestackhci.models.ExtendedLocation - :keyword container_id: Storage ContainerID of the storage container to be used for marketplace - gallery image. - :paramtype container_id: str - :keyword os_type: Operating system type that the gallery image uses [Windows, Linux]. Known - values are: "Windows" and "Linux". - :paramtype os_type: str or ~azure.mgmt.azurestackhci.models.OperatingSystemTypes - :keyword cloud_init_data_source: Datasource for the gallery image when provisioning with - cloud-init [NoCloud, Azure]. Known values are: "NoCloud" and "Azure". - :paramtype cloud_init_data_source: str or ~azure.mgmt.azurestackhci.models.CloudInitDataSource - :keyword hyper_v_generation: The hypervisor generation of the Virtual Machine [V1, V2]. Known - values are: "V1" and "V2". - :paramtype hyper_v_generation: str or ~azure.mgmt.azurestackhci.models.HyperVGeneration - :keyword identifier: This is the gallery image definition identifier. - :paramtype identifier: ~azure.mgmt.azurestackhci.models.GalleryImageIdentifier - :keyword version: Specifies information about the gallery image version that you want to create - or update. - :paramtype version: ~azure.mgmt.azurestackhci.models.GalleryImageVersion + :keyword ip_configurations: IPConfigurations - A list of IPConfigurations of the network + interface. + :paramtype ip_configurations: list[~azure.mgmt.azurestackhci.models.IPConfiguration] + :keyword mac_address: MacAddress - The MAC address of the network interface. + :paramtype mac_address: str + :keyword dns_settings: DNS Settings for the interface. + :paramtype dns_settings: ~azure.mgmt.azurestackhci.models.InterfaceDNSSettings + """ + super().__init__(tags=tags, location=location, **kwargs) + self.extended_location = extended_location + self.ip_configurations = ip_configurations + self.mac_address = mac_address + self.dns_settings = dns_settings + self.provisioning_state = None + self.status = None + + +class NetworkInterfacesListResult(_serialization.Model): + """NetworkInterfacesListResult. + + :ivar value: + :vartype value: list[~azure.mgmt.azurestackhci.models.NetworkInterfaces] + :ivar next_link: + :vartype next_link: str + """ + + _attribute_map = { + "value": {"key": "value", "type": "[NetworkInterfaces]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, + *, + value: Optional[List["_models.NetworkInterfaces"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword value: + :paramtype value: list[~azure.mgmt.azurestackhci.models.NetworkInterfaces] + :keyword next_link: + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class NetworkInterfaceStatus(_serialization.Model): + """The observed state of network interfaces. + + :ivar error_code: NetworkInterface provisioning error code. + :vartype error_code: str + :ivar error_message: Descriptive error message. + :vartype error_message: str + :ivar provisioning_status: + :vartype provisioning_status: + ~azure.mgmt.azurestackhci.models.NetworkInterfaceStatusProvisioningStatus + """ + + _attribute_map = { + "error_code": {"key": "errorCode", "type": "str"}, + "error_message": {"key": "errorMessage", "type": "str"}, + "provisioning_status": {"key": "provisioningStatus", "type": "NetworkInterfaceStatusProvisioningStatus"}, + } + + def __init__( + self, + *, + error_code: Optional[str] = None, + error_message: Optional[str] = None, + provisioning_status: Optional["_models.NetworkInterfaceStatusProvisioningStatus"] = None, + **kwargs: Any + ) -> None: + """ + :keyword error_code: NetworkInterface provisioning error code. + :paramtype error_code: str + :keyword error_message: Descriptive error message. + :paramtype error_message: str + :keyword provisioning_status: + :paramtype provisioning_status: + ~azure.mgmt.azurestackhci.models.NetworkInterfaceStatusProvisioningStatus + """ + super().__init__(**kwargs) + self.error_code = error_code + self.error_message = error_message + self.provisioning_status = provisioning_status + + +class NetworkInterfaceStatusProvisioningStatus(_serialization.Model): + """NetworkInterfaceStatusProvisioningStatus. + + :ivar operation_id: The ID of the operation performed on the network interface. + :vartype operation_id: str + :ivar status: The status of the operation performed on the network interface [Succeeded, + Failed, InProgress]. Known values are: "NotYetRegistered", "ConnectedRecently", + "NotConnectedRecently", "Disconnected", "Error", "NotSpecified", "ValidationInProgress", + "ValidationSuccess", "ValidationFailed", "DeploymentInProgress", "DeploymentFailed", + "DeploymentSuccess", "Succeeded", "Failed", and "InProgress". + :vartype status: str or ~azure.mgmt.azurestackhci.models.Status + """ + + _attribute_map = { + "operation_id": {"key": "operationId", "type": "str"}, + "status": {"key": "status", "type": "str"}, + } + + def __init__( + self, + *, + operation_id: Optional[str] = None, + status: Optional[Union[str, "_models.Status"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword operation_id: The ID of the operation performed on the network interface. + :paramtype operation_id: str + :keyword status: The status of the operation performed on the network interface [Succeeded, + Failed, InProgress]. Known values are: "NotYetRegistered", "ConnectedRecently", + "NotConnectedRecently", "Disconnected", "Error", "NotSpecified", "ValidationInProgress", + "ValidationSuccess", "ValidationFailed", "DeploymentInProgress", "DeploymentFailed", + "DeploymentSuccess", "Succeeded", "Failed", and "InProgress". + :paramtype status: str or ~azure.mgmt.azurestackhci.models.Status + """ + super().__init__(**kwargs) + self.operation_id = operation_id + self.status = status + + +class NetworkInterfacesUpdateRequest(_serialization.Model): + """The network interface resource patch definition. + + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + } + + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.tags = tags + + +class NetworkProfileUpdate(_serialization.Model): + """NetworkProfile - describes the network update configuration the virtual machine instance. + + :ivar network_interfaces: NetworkInterfaces - list of network interfaces to be attached to the + virtual machine instance. + :vartype network_interfaces: + list[~azure.mgmt.azurestackhci.models.NetworkProfileUpdateNetworkInterfacesItem] + """ + + _attribute_map = { + "network_interfaces": {"key": "networkInterfaces", "type": "[NetworkProfileUpdateNetworkInterfacesItem]"}, + } + + def __init__( + self, + *, + network_interfaces: Optional[List["_models.NetworkProfileUpdateNetworkInterfacesItem"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword network_interfaces: NetworkInterfaces - list of network interfaces to be attached to + the virtual machine instance. + :paramtype network_interfaces: + list[~azure.mgmt.azurestackhci.models.NetworkProfileUpdateNetworkInterfacesItem] + """ + super().__init__(**kwargs) + self.network_interfaces = network_interfaces + + +class NetworkProfileUpdateNetworkInterfacesItem(_serialization.Model): # pylint: disable=name-too-long + """NetworkProfileUpdateNetworkInterfacesItem. + + :ivar id: ID - Resource ID of the network interface. + :vartype id: str + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + } + + def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin + """ + :keyword id: ID - Resource ID of the network interface. + :paramtype id: str + """ + super().__init__(**kwargs) + self.id = id + + +class NicDetail(_serialization.Model): + """The NIC Detail of a device. + + All required parameters must be populated in order to send to server. + + :ivar adapter_name: Adapter Name of NIC. Required. + :vartype adapter_name: str + :ivar interface_description: Interface Description of NIC. + :vartype interface_description: str + :ivar component_id: Component Id of NIC. + :vartype component_id: str + :ivar driver_version: Driver Version of NIC. + :vartype driver_version: str + :ivar ip4_address: Subnet Mask of NIC. + :vartype ip4_address: str + :ivar subnet_mask: Subnet Mask of NIC. + :vartype subnet_mask: str + :ivar default_gateway: Default Gateway of NIC. + :vartype default_gateway: str + :ivar dns_servers: DNS Servers for NIC. + :vartype dns_servers: list[str] + :ivar default_isolation_id: Default Isolation of Management NIC. + :vartype default_isolation_id: str + """ + + _validation = { + "adapter_name": {"required": True}, + } + + _attribute_map = { + "adapter_name": {"key": "adapterName", "type": "str"}, + "interface_description": {"key": "interfaceDescription", "type": "str"}, + "component_id": {"key": "componentId", "type": "str"}, + "driver_version": {"key": "driverVersion", "type": "str"}, + "ip4_address": {"key": "ip4Address", "type": "str"}, + "subnet_mask": {"key": "subnetMask", "type": "str"}, + "default_gateway": {"key": "defaultGateway", "type": "str"}, + "dns_servers": {"key": "dnsServers", "type": "[str]"}, + "default_isolation_id": {"key": "defaultIsolationId", "type": "str"}, + } + + def __init__( + self, + *, + adapter_name: str, + interface_description: Optional[str] = None, + component_id: Optional[str] = None, + driver_version: Optional[str] = None, + ip4_address: Optional[str] = None, + subnet_mask: Optional[str] = None, + default_gateway: Optional[str] = None, + dns_servers: Optional[List[str]] = None, + default_isolation_id: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword adapter_name: Adapter Name of NIC. Required. + :paramtype adapter_name: str + :keyword interface_description: Interface Description of NIC. + :paramtype interface_description: str + :keyword component_id: Component Id of NIC. + :paramtype component_id: str + :keyword driver_version: Driver Version of NIC. + :paramtype driver_version: str + :keyword ip4_address: Subnet Mask of NIC. + :paramtype ip4_address: str + :keyword subnet_mask: Subnet Mask of NIC. + :paramtype subnet_mask: str + :keyword default_gateway: Default Gateway of NIC. + :paramtype default_gateway: str + :keyword dns_servers: DNS Servers for NIC. + :paramtype dns_servers: list[str] + :keyword default_isolation_id: Default Isolation of Management NIC. + :paramtype default_isolation_id: str + """ + super().__init__(**kwargs) + self.adapter_name = adapter_name + self.interface_description = interface_description + self.component_id = component_id + self.driver_version = driver_version + self.ip4_address = ip4_address + self.subnet_mask = subnet_mask + self.default_gateway = default_gateway + self.dns_servers = dns_servers + self.default_isolation_id = default_isolation_id + + +class Observability(_serialization.Model): + """The Observability of AzureStackHCI Cluster. + + :ivar streaming_data_client: Enables telemetry data to be sent to Microsoft. + :vartype streaming_data_client: bool + :ivar eu_location: Location of your cluster. The log and diagnostic data is sent to the + appropriate diagnostics servers depending upon where your cluster resides. Setting this to + false results in all data sent to Microsoft to be stored outside of the EU. + :vartype eu_location: bool + :ivar episodic_data_upload: When set to true, collects log data to facilitate quicker issue + resolution. + :vartype episodic_data_upload: bool + """ + + _attribute_map = { + "streaming_data_client": {"key": "streamingDataClient", "type": "bool"}, + "eu_location": {"key": "euLocation", "type": "bool"}, + "episodic_data_upload": {"key": "episodicDataUpload", "type": "bool"}, + } + + def __init__( + self, + *, + streaming_data_client: bool = True, + eu_location: bool = False, + episodic_data_upload: bool = True, + **kwargs: Any + ) -> None: + """ + :keyword streaming_data_client: Enables telemetry data to be sent to Microsoft. + :paramtype streaming_data_client: bool + :keyword eu_location: Location of your cluster. The log and diagnostic data is sent to the + appropriate diagnostics servers depending upon where your cluster resides. Setting this to + false results in all data sent to Microsoft to be stored outside of the EU. + :paramtype eu_location: bool + :keyword episodic_data_upload: When set to true, collects log data to facilitate quicker issue + resolution. + :paramtype episodic_data_upload: bool + """ + super().__init__(**kwargs) + self.streaming_data_client = streaming_data_client + self.eu_location = eu_location + self.episodic_data_upload = episodic_data_upload + + +class Offer(ProxyResource): + """Offer details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.azurestackhci.models.SystemData + :ivar provisioning_state: Provisioning State. + :vartype provisioning_state: str + :ivar publisher_id: Identifier of the Publisher for the offer. + :vartype publisher_id: str + :ivar content: JSON serialized catalog content of the offer. + :vartype content: str + :ivar content_version: The API version of the catalog service used to serve the catalog + content. + :vartype content_version: str + :ivar sku_mappings: Array of SKU mappings. + :vartype sku_mappings: list[~azure.mgmt.azurestackhci.models.SkuMappings] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "publisher_id": {"key": "properties.publisherId", "type": "str"}, + "content": {"key": "properties.content", "type": "str"}, + "content_version": {"key": "properties.contentVersion", "type": "str"}, + "sku_mappings": {"key": "properties.skuMappings", "type": "[SkuMappings]"}, + } + + def __init__( + self, + *, + publisher_id: Optional[str] = None, + content: Optional[str] = None, + content_version: Optional[str] = None, + sku_mappings: Optional[List["_models.SkuMappings"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword publisher_id: Identifier of the Publisher for the offer. + :paramtype publisher_id: str + :keyword content: JSON serialized catalog content of the offer. + :paramtype content: str + :keyword content_version: The API version of the catalog service used to serve the catalog + content. + :paramtype content_version: str + :keyword sku_mappings: Array of SKU mappings. + :paramtype sku_mappings: list[~azure.mgmt.azurestackhci.models.SkuMappings] + """ + super().__init__(**kwargs) + self.provisioning_state = None + self.publisher_id = publisher_id + self.content = content + self.content_version = content_version + self.sku_mappings = sku_mappings + + +class OfferList(_serialization.Model): + """List of Offer proxy resources for the HCI cluster. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of Offer proxy resources. + :vartype value: list[~azure.mgmt.azurestackhci.models.Offer] + :ivar next_link: Link to the next set of results. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Offer]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class Operation(_serialization.Model): + """Details of a REST API operation, returned from the Resource Provider Operations API. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + :vartype name: str + :ivar is_data_action: Whether the operation applies to data-plane. This is "true" for + data-plane operations and "false" for ARM/control-plane operations. + :vartype is_data_action: bool + :ivar display: Localized display information for this particular operation. + :vartype display: ~azure.mgmt.azurestackhci.models.OperationDisplay + :ivar origin: The intended executor of the operation; as in Resource Based Access Control + (RBAC) and audit logs UX. Default value is "user,system". Known values are: "user", "system", + and "user,system". + :vartype origin: str or ~azure.mgmt.azurestackhci.models.Origin + :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for + internal only APIs. "Internal" + :vartype action_type: str or ~azure.mgmt.azurestackhci.models.ActionType + """ + + _validation = { + "name": {"readonly": True}, + "is_data_action": {"readonly": True}, + "origin": {"readonly": True}, + "action_type": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "origin": {"key": "origin", "type": "str"}, + "action_type": {"key": "actionType", "type": "str"}, + } + + def __init__(self, *, display: Optional["_models.OperationDisplay"] = None, **kwargs: Any) -> None: + """ + :keyword display: Localized display information for this particular operation. + :paramtype display: ~azure.mgmt.azurestackhci.models.OperationDisplay + """ + super().__init__(**kwargs) + self.name = None + self.is_data_action = None + self.display = display + self.origin = None + self.action_type = None + + +class OperationDisplay(_serialization.Model): + """Localized display information for this particular operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provider: The localized friendly form of the resource provider name, e.g. "Microsoft + Monitoring Insights" or "Microsoft Compute". + :vartype provider: str + :ivar resource: The localized friendly name of the resource type related to this operation. + E.g. "Virtual Machines" or "Job Schedule Collections". + :vartype resource: str + :ivar operation: The concise, localized friendly name for the operation; suitable for + dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". + :vartype operation: str + :ivar description: The short, localized friendly description of the operation; suitable for + tool tips and detailed views. + :vartype description: str + """ + + _validation = { + "provider": {"readonly": True}, + "resource": {"readonly": True}, + "operation": {"readonly": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.provider = None + self.resource = None + self.operation = None + self.description = None + + +class OperationListResult(_serialization.Model): + """A list of REST API operations supported by an Azure Resource Provider. It contains an URL link + to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of operations supported by the resource provider. + :vartype value: list[~azure.mgmt.azurestackhci.models.Operation] + :ivar next_link: URL to get the next set of operation list results (if there are any). + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class OptionalServices(_serialization.Model): + """The OptionalServices of AzureStackHCI Cluster. + + :ivar custom_location: The name of custom location. + :vartype custom_location: str + """ + + _attribute_map = { + "custom_location": {"key": "customLocation", "type": "str"}, + } + + def __init__(self, *, custom_location: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword custom_location: The name of custom location. + :paramtype custom_location: str + """ + super().__init__(**kwargs) + self.custom_location = custom_location + + +class OsProfileUpdate(_serialization.Model): + """OsProfile - describes the update configuration of the operating system. + + :ivar computer_name: ComputerName - name of the computer. + :vartype computer_name: str + :ivar linux_configuration: + :vartype linux_configuration: + ~azure.mgmt.azurestackhci.models.OsProfileUpdateLinuxConfiguration + :ivar windows_configuration: + :vartype windows_configuration: + ~azure.mgmt.azurestackhci.models.OsProfileUpdateWindowsConfiguration + """ + + _attribute_map = { + "computer_name": {"key": "computerName", "type": "str"}, + "linux_configuration": {"key": "linuxConfiguration", "type": "OsProfileUpdateLinuxConfiguration"}, + "windows_configuration": {"key": "windowsConfiguration", "type": "OsProfileUpdateWindowsConfiguration"}, + } + + def __init__( + self, + *, + computer_name: Optional[str] = None, + linux_configuration: Optional["_models.OsProfileUpdateLinuxConfiguration"] = None, + windows_configuration: Optional["_models.OsProfileUpdateWindowsConfiguration"] = None, + **kwargs: Any + ) -> None: + """ + :keyword computer_name: ComputerName - name of the computer. + :paramtype computer_name: str + :keyword linux_configuration: + :paramtype linux_configuration: + ~azure.mgmt.azurestackhci.models.OsProfileUpdateLinuxConfiguration + :keyword windows_configuration: + :paramtype windows_configuration: + ~azure.mgmt.azurestackhci.models.OsProfileUpdateWindowsConfiguration + """ + super().__init__(**kwargs) + self.computer_name = computer_name + self.linux_configuration = linux_configuration + self.windows_configuration = windows_configuration + + +class OsProfileUpdateLinuxConfiguration(_serialization.Model): + """OsProfileUpdateLinuxConfiguration. + + :ivar provision_vm_agent: Used to indicate whether Arc for Servers agent onboarding should be + triggered during the virtual machine instance creation process. + :vartype provision_vm_agent: bool + :ivar provision_vm_config_agent: Used to indicate whether the VM Config Agent should be + installed during the virtual machine creation process. + :vartype provision_vm_config_agent: bool + """ + + _attribute_map = { + "provision_vm_agent": {"key": "provisionVMAgent", "type": "bool"}, + "provision_vm_config_agent": {"key": "provisionVMConfigAgent", "type": "bool"}, + } + + def __init__( + self, + *, + provision_vm_agent: Optional[bool] = None, + provision_vm_config_agent: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword provision_vm_agent: Used to indicate whether Arc for Servers agent onboarding should + be triggered during the virtual machine instance creation process. + :paramtype provision_vm_agent: bool + :keyword provision_vm_config_agent: Used to indicate whether the VM Config Agent should be + installed during the virtual machine creation process. + :paramtype provision_vm_config_agent: bool + """ + super().__init__(**kwargs) + self.provision_vm_agent = provision_vm_agent + self.provision_vm_config_agent = provision_vm_config_agent + + +class OsProfileUpdateWindowsConfiguration(_serialization.Model): + """OsProfileUpdateWindowsConfiguration. + + :ivar provision_vm_agent: Used to indicate whether Arc for Servers agent onboarding should be + triggered during the virtual machine instance creation process. + :vartype provision_vm_agent: bool + :ivar provision_vm_config_agent: Used to indicate whether the VM Config Agent should be + installed during the virtual machine creation process. + :vartype provision_vm_config_agent: bool + """ + + _attribute_map = { + "provision_vm_agent": {"key": "provisionVMAgent", "type": "bool"}, + "provision_vm_config_agent": {"key": "provisionVMConfigAgent", "type": "bool"}, + } + + def __init__( + self, + *, + provision_vm_agent: Optional[bool] = None, + provision_vm_config_agent: Optional[bool] = None, + **kwargs: Any + ) -> None: + """ + :keyword provision_vm_agent: Used to indicate whether Arc for Servers agent onboarding should + be triggered during the virtual machine instance creation process. + :paramtype provision_vm_agent: bool + :keyword provision_vm_config_agent: Used to indicate whether the VM Config Agent should be + installed during the virtual machine creation process. + :paramtype provision_vm_config_agent: bool + """ + super().__init__(**kwargs) + self.provision_vm_agent = provision_vm_agent + self.provision_vm_config_agent = provision_vm_config_agent + + +class PackageVersionInfo(_serialization.Model): + """Current version of each updatable component. + + :ivar package_type: Package type. + :vartype package_type: str + :ivar version: Package version. + :vartype version: str + :ivar last_updated: Last time this component was updated. + :vartype last_updated: ~datetime.datetime + """ + + _attribute_map = { + "package_type": {"key": "packageType", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "last_updated": {"key": "lastUpdated", "type": "iso-8601"}, + } + + def __init__( + self, + *, + package_type: Optional[str] = None, + version: Optional[str] = None, + last_updated: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :keyword package_type: Package type. + :paramtype package_type: str + :keyword version: Package version. + :paramtype version: str + :keyword last_updated: Last time this component was updated. + :paramtype last_updated: ~datetime.datetime + """ + super().__init__(**kwargs) + self.package_type = package_type + self.version = version + self.last_updated = last_updated + + +class PasswordCredential(_serialization.Model): + """PasswordCredential. + + :ivar secret_text: + :vartype secret_text: str + :ivar key_id: + :vartype key_id: str + :ivar start_date_time: + :vartype start_date_time: ~datetime.datetime + :ivar end_date_time: + :vartype end_date_time: ~datetime.datetime + """ + + _attribute_map = { + "secret_text": {"key": "secretText", "type": "str"}, + "key_id": {"key": "keyId", "type": "str"}, + "start_date_time": {"key": "startDateTime", "type": "iso-8601"}, + "end_date_time": {"key": "endDateTime", "type": "iso-8601"}, + } + + def __init__( + self, + *, + secret_text: Optional[str] = None, + key_id: Optional[str] = None, + start_date_time: Optional[datetime.datetime] = None, + end_date_time: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :keyword secret_text: + :paramtype secret_text: str + :keyword key_id: + :paramtype key_id: str + :keyword start_date_time: + :paramtype start_date_time: ~datetime.datetime + :keyword end_date_time: + :paramtype end_date_time: ~datetime.datetime + """ + super().__init__(**kwargs) + self.secret_text = secret_text + self.key_id = key_id + self.start_date_time = start_date_time + self.end_date_time = end_date_time + + +class PerNodeExtensionState(_serialization.Model): + """Status of Arc Extension for a particular node in HCI Cluster. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Name of the node in HCI Cluster. + :vartype name: str + :ivar extension: Fully qualified resource ID for the particular Arc Extension on this node. + :vartype extension: str + :ivar type_handler_version: Specifies the version of the script handler. + :vartype type_handler_version: str + :ivar state: State of Arc Extension in this node. Known values are: "NotSpecified", "Error", + "Succeeded", "Canceled", "Failed", "Connected", "Disconnected", "Deleted", "Creating", + "Updating", "Deleting", "Moving", "PartiallySucceeded", "PartiallyConnected", "InProgress", + "Accepted", and "Provisioning". + :vartype state: str or ~azure.mgmt.azurestackhci.models.NodeExtensionState + :ivar instance_view: The extension instance view. + :vartype instance_view: ~azure.mgmt.azurestackhci.models.ExtensionInstanceView + """ + + _validation = { + "name": {"readonly": True}, + "extension": {"readonly": True}, + "type_handler_version": {"readonly": True}, + "state": {"readonly": True}, + "instance_view": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "extension": {"key": "extension", "type": "str"}, + "type_handler_version": {"key": "typeHandlerVersion", "type": "str"}, + "state": {"key": "state", "type": "str"}, + "instance_view": {"key": "instanceView", "type": "ExtensionInstanceView"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.name = None + self.extension = None + self.type_handler_version = None + self.state = None + self.instance_view = None + + +class PerNodeState(_serialization.Model): + """Status of Arc agent for a particular node in HCI Cluster. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Name of the Node in HCI Cluster. + :vartype name: str + :ivar arc_instance: Fully qualified resource ID for the Arc agent of this node. + :vartype arc_instance: str + :ivar arc_node_service_principal_object_id: The service principal id of the arc for server + node. + :vartype arc_node_service_principal_object_id: str + :ivar state: State of Arc agent in this node. Known values are: "NotSpecified", "Error", + "Succeeded", "Canceled", "Failed", "Connected", "Disconnected", "Deleted", "Creating", + "Updating", "Deleting", "Moving", "PartiallySucceeded", "PartiallyConnected", "InProgress", + "Accepted", "Provisioning", and "DisableInProgress". + :vartype state: str or ~azure.mgmt.azurestackhci.models.NodeArcState + """ + + _validation = { + "name": {"readonly": True}, + "arc_instance": {"readonly": True}, + "arc_node_service_principal_object_id": {"readonly": True}, + "state": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "arc_instance": {"key": "arcInstance", "type": "str"}, + "arc_node_service_principal_object_id": {"key": "arcNodeServicePrincipalObjectId", "type": "str"}, + "state": {"key": "state", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.name = None + self.arc_instance = None + self.arc_node_service_principal_object_id = None + self.state = None + + +class PhysicalNodes(_serialization.Model): + """The PhysicalNodes of a cluster. + + :ivar name: NETBIOS name of each physical server on your Azure Stack HCI cluster. + :vartype name: str + :ivar ipv4_address: The IPv4 address assigned to each physical server on your Azure Stack HCI + cluster. + :vartype ipv4_address: str + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "ipv4_address": {"key": "ipv4Address", "type": "str"}, + } + + def __init__(self, *, name: Optional[str] = None, ipv4_address: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword name: NETBIOS name of each physical server on your Azure Stack HCI cluster. + :paramtype name: str + :keyword ipv4_address: The IPv4 address assigned to each physical server on your Azure Stack + HCI cluster. + :paramtype ipv4_address: str + """ + super().__init__(**kwargs) + self.name = name + self.ipv4_address = ipv4_address + + +class PrecheckResult(_serialization.Model): # pylint: disable=too-many-instance-attributes + """PrecheckResult. + + :ivar name: Name of the individual test/rule/alert that was executed. Unique, not exposed to + the customer. + :vartype name: str + :ivar display_name: The health check DisplayName localized of the individual test executed. + :vartype display_name: str + :ivar tags: Key-value pairs that allow grouping/filtering individual tests. + :vartype tags: ~azure.mgmt.azurestackhci.models.PrecheckResultTags + :ivar title: User-facing name; one or more sentences indicating the direct issue. + :vartype title: str + :ivar status: The status of the check running (i.e. Failed, Succeeded, In Progress). This + answers whether the check ran, and passed or failed. Known values are: "NotYetRegistered", + "ConnectedRecently", "NotConnectedRecently", "Disconnected", "Error", "NotSpecified", + "ValidationInProgress", "ValidationSuccess", "ValidationFailed", "DeploymentInProgress", + "DeploymentFailed", "DeploymentSuccess", "Succeeded", "Failed", and "InProgress". + :vartype status: str or ~azure.mgmt.azurestackhci.models.Status + :ivar severity: Severity of the result (Critical, Warning, Informational, Hidden). This answers + how important the result is. Critical is the only update-blocking severity. Known values are: + "Critical", "Warning", "Informational", and "Hidden". + :vartype severity: str or ~azure.mgmt.azurestackhci.models.Severity + :ivar description: Detailed overview of the issue and what impact the issue has on the stamp. + :vartype description: str + :ivar remediation: Set of steps that can be taken to resolve the issue found. + :vartype remediation: str + :ivar target_resource_id: The unique identifier for the affected resource (such as a node or + drive). + :vartype target_resource_id: str + :ivar target_resource_name: The name of the affected resource. + :vartype target_resource_name: str + :ivar timestamp: The Time in which the HealthCheck was called. + :vartype timestamp: ~datetime.datetime + :ivar additional_data: Property bag of key value pairs for additional information. + :vartype additional_data: str + :ivar health_check_source: The name of the services called for the HealthCheck (I.E. + Test-AzureStack, Test-Cluster). + :vartype health_check_source: str + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "tags": {"key": "tags", "type": "PrecheckResultTags"}, + "title": {"key": "title", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "severity": {"key": "severity", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "remediation": {"key": "remediation", "type": "str"}, + "target_resource_id": {"key": "targetResourceID", "type": "str"}, + "target_resource_name": {"key": "targetResourceName", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "additional_data": {"key": "additionalData", "type": "str"}, + "health_check_source": {"key": "healthCheckSource", "type": "str"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + display_name: Optional[str] = None, + tags: Optional["_models.PrecheckResultTags"] = None, + title: Optional[str] = None, + status: Optional[Union[str, "_models.Status"]] = None, + severity: Optional[Union[str, "_models.Severity"]] = None, + description: Optional[str] = None, + remediation: Optional[str] = None, + target_resource_id: Optional[str] = None, + target_resource_name: Optional[str] = None, + timestamp: Optional[datetime.datetime] = None, + additional_data: Optional[str] = None, + health_check_source: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: Name of the individual test/rule/alert that was executed. Unique, not exposed to + the customer. + :paramtype name: str + :keyword display_name: The health check DisplayName localized of the individual test executed. + :paramtype display_name: str + :keyword tags: Key-value pairs that allow grouping/filtering individual tests. + :paramtype tags: ~azure.mgmt.azurestackhci.models.PrecheckResultTags + :keyword title: User-facing name; one or more sentences indicating the direct issue. + :paramtype title: str + :keyword status: The status of the check running (i.e. Failed, Succeeded, In Progress). This + answers whether the check ran, and passed or failed. Known values are: "NotYetRegistered", + "ConnectedRecently", "NotConnectedRecently", "Disconnected", "Error", "NotSpecified", + "ValidationInProgress", "ValidationSuccess", "ValidationFailed", "DeploymentInProgress", + "DeploymentFailed", "DeploymentSuccess", "Succeeded", "Failed", and "InProgress". + :paramtype status: str or ~azure.mgmt.azurestackhci.models.Status + :keyword severity: Severity of the result (Critical, Warning, Informational, Hidden). This + answers how important the result is. Critical is the only update-blocking severity. Known + values are: "Critical", "Warning", "Informational", and "Hidden". + :paramtype severity: str or ~azure.mgmt.azurestackhci.models.Severity + :keyword description: Detailed overview of the issue and what impact the issue has on the + stamp. + :paramtype description: str + :keyword remediation: Set of steps that can be taken to resolve the issue found. + :paramtype remediation: str + :keyword target_resource_id: The unique identifier for the affected resource (such as a node or + drive). + :paramtype target_resource_id: str + :keyword target_resource_name: The name of the affected resource. + :paramtype target_resource_name: str + :keyword timestamp: The Time in which the HealthCheck was called. + :paramtype timestamp: ~datetime.datetime + :keyword additional_data: Property bag of key value pairs for additional information. + :paramtype additional_data: str + :keyword health_check_source: The name of the services called for the HealthCheck (I.E. + Test-AzureStack, Test-Cluster). + :paramtype health_check_source: str + """ + super().__init__(**kwargs) + self.name = name + self.display_name = display_name + self.tags = tags + self.title = title + self.status = status + self.severity = severity + self.description = description + self.remediation = remediation + self.target_resource_id = target_resource_id + self.target_resource_name = target_resource_name + self.timestamp = timestamp + self.additional_data = additional_data + self.health_check_source = health_check_source + + +class PrecheckResultTags(_serialization.Model): + """Key-value pairs that allow grouping/filtering individual tests. + + :ivar key: Key that allow grouping/filtering individual tests. + :vartype key: str + :ivar value: Value of the key that allow grouping/filtering individual tests. + :vartype value: str + """ + + _attribute_map = { + "key": {"key": "key", "type": "str"}, + "value": {"key": "value", "type": "str"}, + } + + def __init__(self, *, key: Optional[str] = None, value: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword key: Key that allow grouping/filtering individual tests. + :paramtype key: str + :keyword value: Value of the key that allow grouping/filtering individual tests. + :paramtype value: str + """ + super().__init__(**kwargs) + self.key = key + self.value = value + + +class Publisher(ProxyResource): + """Publisher details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.azurestackhci.models.SystemData + :ivar provisioning_state: Provisioning State. + :vartype provisioning_state: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.provisioning_state = None + + +class PublisherList(_serialization.Model): + """List of Publisher proxy resources for the HCI cluster. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of Publisher proxy resources. + :vartype value: list[~azure.mgmt.azurestackhci.models.Publisher] + :ivar next_link: Link to the next set of results. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Publisher]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class QosPolicyOverrides(_serialization.Model): + """The QoSPolicyOverrides of a cluster. + + :ivar priority_value8021_action_cluster: This parameter should only be modified based on your + OEM guidance. Do not modify this parameter without OEM validation. + :vartype priority_value8021_action_cluster: str + :ivar priority_value8021_action_smb: This parameter should only be modified based on your OEM + guidance. Do not modify this parameter without OEM validation. + :vartype priority_value8021_action_smb: str + :ivar bandwidth_percentage_smb: This parameter should only be modified based on your OEM + guidance. Do not modify this parameter without OEM validation. + :vartype bandwidth_percentage_smb: str + """ + + _attribute_map = { + "priority_value8021_action_cluster": {"key": "priorityValue8021Action_Cluster", "type": "str"}, + "priority_value8021_action_smb": {"key": "priorityValue8021Action_SMB", "type": "str"}, + "bandwidth_percentage_smb": {"key": "bandwidthPercentage_SMB", "type": "str"}, + } + + def __init__( + self, + *, + priority_value8021_action_cluster: Optional[str] = None, + priority_value8021_action_smb: Optional[str] = None, + bandwidth_percentage_smb: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword priority_value8021_action_cluster: This parameter should only be modified based on + your OEM guidance. Do not modify this parameter without OEM validation. + :paramtype priority_value8021_action_cluster: str + :keyword priority_value8021_action_smb: This parameter should only be modified based on your + OEM guidance. Do not modify this parameter without OEM validation. + :paramtype priority_value8021_action_smb: str + :keyword bandwidth_percentage_smb: This parameter should only be modified based on your OEM + guidance. Do not modify this parameter without OEM validation. + :paramtype bandwidth_percentage_smb: str + """ + super().__init__(**kwargs) + self.priority_value8021_action_cluster = priority_value8021_action_cluster + self.priority_value8021_action_smb = priority_value8021_action_smb + self.bandwidth_percentage_smb = bandwidth_percentage_smb + + +class RawCertificateData(_serialization.Model): + """RawCertificateData. + + :ivar certificates: + :vartype certificates: list[str] + """ + + _attribute_map = { + "certificates": {"key": "certificates", "type": "[str]"}, + } + + def __init__(self, *, certificates: Optional[List[str]] = None, **kwargs: Any) -> None: + """ + :keyword certificates: + :paramtype certificates: list[str] + """ + super().__init__(**kwargs) + self.certificates = certificates + + +class ReportedProperties(_serialization.Model): + """The DeploymentStatus of AzureStackHCI Cluster. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar validation_status: validation status of AzureStackHCI Cluster Deployment. + :vartype validation_status: ~azure.mgmt.azurestackhci.models.ValidationStatus + :ivar deployment_status: Deployment status of AzureStackHCI Cluster Deployment. + :vartype deployment_status: ~azure.mgmt.azurestackhci.models.DeploymentStatus + """ + + _validation = { + "validation_status": {"readonly": True}, + "deployment_status": {"readonly": True}, + } + + _attribute_map = { + "validation_status": {"key": "validationStatus", "type": "ValidationStatus"}, + "deployment_status": {"key": "deploymentStatus", "type": "DeploymentStatus"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.validation_status = None + self.deployment_status = None + + +class Route(_serialization.Model): + """Route - Route resource. + + :ivar name: Name - name of the subnet. + :vartype name: str + :ivar address_prefix: The destination CIDR to which the route applies. + :vartype address_prefix: str + :ivar next_hop_ip_address: The IP address packets should be forwarded to. Next hop values are + only allowed in routes where the next hop type is VirtualAppliance. + :vartype next_hop_ip_address: str + """ + + _validation = { + "name": {"pattern": r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-._a-zA-Z0-9]{0,78}[_a-zA-Z0-9]$"}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "address_prefix": {"key": "properties.addressPrefix", "type": "str"}, + "next_hop_ip_address": {"key": "properties.nextHopIpAddress", "type": "str"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + address_prefix: Optional[str] = None, + next_hop_ip_address: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword name: Name - name of the subnet. + :paramtype name: str + :keyword address_prefix: The destination CIDR to which the route applies. + :paramtype address_prefix: str + :keyword next_hop_ip_address: The IP address packets should be forwarded to. Next hop values + are only allowed in routes where the next hop type is VirtualAppliance. + :paramtype next_hop_ip_address: str + """ + super().__init__(**kwargs) + self.name = name + self.address_prefix = address_prefix + self.next_hop_ip_address = next_hop_ip_address + + +class RouteTable(_serialization.Model): + """Route table resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar etag: A unique read-only string that changes whenever the resource is updated. + :vartype etag: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar routes: Collection of routes contained within a route table. + :vartype routes: list[~azure.mgmt.azurestackhci.models.Route] + """ + + _validation = { + "etag": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "etag": {"key": "etag", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "routes": {"key": "properties.routes", "type": "[Route]"}, + } + + def __init__(self, *, routes: Optional[List["_models.Route"]] = None, **kwargs: Any) -> None: + """ + :keyword routes: Collection of routes contained within a route table. + :paramtype routes: list[~azure.mgmt.azurestackhci.models.Route] + """ + super().__init__(**kwargs) + self.etag = None + self.name = None + self.type = None + self.routes = routes + + +class ScaleUnits(_serialization.Model): + """Scale units will contains list of deployment data. + + All required parameters must be populated in order to send to server. + + :ivar deployment_data: Deployment Data to deploy AzureStackHCI Cluster. Required. + :vartype deployment_data: ~azure.mgmt.azurestackhci.models.DeploymentData + """ + + _validation = { + "deployment_data": {"required": True}, + } + + _attribute_map = { + "deployment_data": {"key": "deploymentData", "type": "DeploymentData"}, + } + + def __init__(self, *, deployment_data: "_models.DeploymentData", **kwargs: Any) -> None: + """ + :keyword deployment_data: Deployment Data to deploy AzureStackHCI Cluster. Required. + :paramtype deployment_data: ~azure.mgmt.azurestackhci.models.DeploymentData + """ + super().__init__(**kwargs) + self.deployment_data = deployment_data + + +class SecurityComplianceStatus(_serialization.Model): + """Security compliance properties of the resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar secured_core_compliance: Indicates whether HCI hosts meets secured-core server + requirements. Known values are: "Compliant", "NonCompliant", and "Pending". + :vartype secured_core_compliance: str or ~azure.mgmt.azurestackhci.models.ComplianceStatus + :ivar wdac_compliance: Indicates whether HCI hosts have enforced consistent Windows Defender + Application Control. Known values are: "Compliant", "NonCompliant", and "Pending". + :vartype wdac_compliance: str or ~azure.mgmt.azurestackhci.models.ComplianceStatus + :ivar data_at_rest_encrypted: Indicates whether data at-rest encryption is enabled on Azure + Stack HCI clustered volumes. Known values are: "Compliant", "NonCompliant", and "Pending". + :vartype data_at_rest_encrypted: str or ~azure.mgmt.azurestackhci.models.ComplianceStatus + :ivar data_in_transit_protected: Indicates whether HCI cluster has data in-transit protection. + Known values are: "Compliant", "NonCompliant", and "Pending". + :vartype data_in_transit_protected: str or ~azure.mgmt.azurestackhci.models.ComplianceStatus + :ivar last_updated: Time in UTC when compliance status was last updated. + :vartype last_updated: ~datetime.datetime + """ + + _validation = { + "secured_core_compliance": {"readonly": True}, + "wdac_compliance": {"readonly": True}, + "data_at_rest_encrypted": {"readonly": True}, + "data_in_transit_protected": {"readonly": True}, + "last_updated": {"readonly": True}, + } + + _attribute_map = { + "secured_core_compliance": {"key": "securedCoreCompliance", "type": "str"}, + "wdac_compliance": {"key": "wdacCompliance", "type": "str"}, + "data_at_rest_encrypted": {"key": "dataAtRestEncrypted", "type": "str"}, + "data_in_transit_protected": {"key": "dataInTransitProtected", "type": "str"}, + "last_updated": {"key": "lastUpdated", "type": "iso-8601"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.secured_core_compliance = None + self.wdac_compliance = None + self.data_at_rest_encrypted = None + self.data_in_transit_protected = None + self.last_updated = None + + +class SecuritySetting(ProxyResource): + """Security settings proxy resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.azurestackhci.models.SystemData + :ivar secured_core_compliance_assignment: Secured Core Compliance Assignment. Known values are: + "Audit" and "ApplyAndAutoCorrect". + :vartype secured_core_compliance_assignment: str or + ~azure.mgmt.azurestackhci.models.ComplianceAssignmentType + :ivar security_compliance_status: Security Compliance Status. + :vartype security_compliance_status: ~azure.mgmt.azurestackhci.models.SecurityComplianceStatus + :ivar provisioning_state: The status of the last operation. Known values are: "NotSpecified", + "Error", "Succeeded", "Failed", "Canceled", "Connected", "Disconnected", "Deleted", "Creating", + "Updating", "Deleting", "Moving", "PartiallySucceeded", "PartiallyConnected", "InProgress", + "Accepted", "Provisioning", and "DisableInProgress". + :vartype provisioning_state: str or ~azure.mgmt.azurestackhci.models.ProvisioningState + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "security_compliance_status": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "secured_core_compliance_assignment": {"key": "properties.securedCoreComplianceAssignment", "type": "str"}, + "security_compliance_status": { + "key": "properties.securityComplianceStatus", + "type": "SecurityComplianceStatus", + }, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + } + + def __init__( + self, + *, + secured_core_compliance_assignment: Optional[Union[str, "_models.ComplianceAssignmentType"]] = None, + provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword secured_core_compliance_assignment: Secured Core Compliance Assignment. Known values + are: "Audit" and "ApplyAndAutoCorrect". + :paramtype secured_core_compliance_assignment: str or + ~azure.mgmt.azurestackhci.models.ComplianceAssignmentType + :keyword provisioning_state: The status of the last operation. Known values are: + "NotSpecified", "Error", "Succeeded", "Failed", "Canceled", "Connected", "Disconnected", + "Deleted", "Creating", "Updating", "Deleting", "Moving", "PartiallySucceeded", + "PartiallyConnected", "InProgress", "Accepted", "Provisioning", and "DisableInProgress". + :paramtype provisioning_state: str or ~azure.mgmt.azurestackhci.models.ProvisioningState + """ + super().__init__(**kwargs) + self.secured_core_compliance_assignment = secured_core_compliance_assignment + self.security_compliance_status = None + self.provisioning_state = provisioning_state + + +class SecuritySettingListResult(_serialization.Model): + """The response of a SecuritySetting list operation. + + All required parameters must be populated in order to send to server. + + :ivar value: The SecuritySetting items on this page. Required. + :vartype value: list[~azure.mgmt.azurestackhci.models.SecuritySetting] + :ivar next_link: The link to the next page of items. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[SecuritySetting]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: List["_models.SecuritySetting"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: The SecuritySetting items on this page. Required. + :paramtype value: list[~azure.mgmt.azurestackhci.models.SecuritySetting] + :keyword next_link: The link to the next page of items. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ServiceConfiguration(_serialization.Model): + """Service configuration details. + + All required parameters must be populated in order to send to server. + + :ivar service_name: Name of the service. Required. "WAC" + :vartype service_name: str or ~azure.mgmt.azurestackhci.models.ServiceName + :ivar port: The port on which service is enabled. Required. + :vartype port: int + """ + + _validation = { + "service_name": {"required": True}, + "port": {"required": True}, + } + + _attribute_map = { + "service_name": {"key": "serviceName", "type": "str"}, + "port": {"key": "port", "type": "int"}, + } + + def __init__(self, *, service_name: Union[str, "_models.ServiceName"], port: int, **kwargs: Any) -> None: + """ + :keyword service_name: Name of the service. Required. "WAC" + :paramtype service_name: str or ~azure.mgmt.azurestackhci.models.ServiceName + :keyword port: The port on which service is enabled. Required. + :paramtype port: int + """ + super().__init__(**kwargs) + self.service_name = service_name + self.port = port + + +class Sku(ProxyResource): + """Sku details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.azurestackhci.models.SystemData + :ivar provisioning_state: Provisioning State. + :vartype provisioning_state: str + :ivar publisher_id: Identifier of the Publisher for the offer. + :vartype publisher_id: str + :ivar offer_id: Identifier of the Offer for the sku. + :vartype offer_id: str + :ivar content: JSON serialized catalog content of the sku offer. + :vartype content: str + :ivar content_version: The API version of the catalog service used to serve the catalog + content. + :vartype content_version: str + :ivar sku_mappings: Array of SKU mappings. + :vartype sku_mappings: list[~azure.mgmt.azurestackhci.models.SkuMappings] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "publisher_id": {"key": "properties.publisherId", "type": "str"}, + "offer_id": {"key": "properties.offerId", "type": "str"}, + "content": {"key": "properties.content", "type": "str"}, + "content_version": {"key": "properties.contentVersion", "type": "str"}, + "sku_mappings": {"key": "properties.skuMappings", "type": "[SkuMappings]"}, + } + + def __init__( + self, + *, + publisher_id: Optional[str] = None, + offer_id: Optional[str] = None, + content: Optional[str] = None, + content_version: Optional[str] = None, + sku_mappings: Optional[List["_models.SkuMappings"]] = None, + **kwargs: Any + ) -> None: """ - super().__init__(tags=tags, location=location, **kwargs) - self.extended_location = extended_location - self.container_id = container_id - self.os_type = os_type - self.cloud_init_data_source = cloud_init_data_source - self.hyper_v_generation = hyper_v_generation - self.identifier = identifier - self.version = version + :keyword publisher_id: Identifier of the Publisher for the offer. + :paramtype publisher_id: str + :keyword offer_id: Identifier of the Offer for the sku. + :paramtype offer_id: str + :keyword content: JSON serialized catalog content of the sku offer. + :paramtype content: str + :keyword content_version: The API version of the catalog service used to serve the catalog + content. + :paramtype content_version: str + :keyword sku_mappings: Array of SKU mappings. + :paramtype sku_mappings: list[~azure.mgmt.azurestackhci.models.SkuMappings] + """ + super().__init__(**kwargs) self.provisioning_state = None - self.status = None + self.publisher_id = publisher_id + self.offer_id = offer_id + self.content = content + self.content_version = content_version + self.sku_mappings = sku_mappings -class MarketplaceGalleryImagesListResult(_serialization.Model): - """MarketplaceGalleryImagesListResult. +class SkuList(_serialization.Model): + """List of SKU proxy resources for the HCI cluster. - :ivar value: - :vartype value: list[~azure.mgmt.azurestackhci.models.MarketplaceGalleryImages] - :ivar next_link: + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of SKU proxy resources. + :vartype value: list[~azure.mgmt.azurestackhci.models.Sku] + :ivar next_link: Link to the next set of results. :vartype next_link: str """ + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + _attribute_map = { - "value": {"key": "value", "type": "[MarketplaceGalleryImages]"}, + "value": {"key": "value", "type": "[Sku]"}, "next_link": {"key": "nextLink", "type": "str"}, } + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class SkuMappings(_serialization.Model): + """SKU Mapping details. + + :ivar catalog_plan_id: Identifier of the CatalogPlan for the sku. + :vartype catalog_plan_id: str + :ivar marketplace_sku_id: Identifier for the sku. + :vartype marketplace_sku_id: str + :ivar marketplace_sku_versions: Array of SKU versions available. + :vartype marketplace_sku_versions: list[str] + """ + + _attribute_map = { + "catalog_plan_id": {"key": "catalogPlanId", "type": "str"}, + "marketplace_sku_id": {"key": "marketplaceSkuId", "type": "str"}, + "marketplace_sku_versions": {"key": "marketplaceSkuVersions", "type": "[str]"}, + } + def __init__( self, *, - value: Optional[List["_models.MarketplaceGalleryImages"]] = None, - next_link: Optional[str] = None, + catalog_plan_id: Optional[str] = None, + marketplace_sku_id: Optional[str] = None, + marketplace_sku_versions: Optional[List[str]] = None, **kwargs: Any ) -> None: """ - :keyword value: - :paramtype value: list[~azure.mgmt.azurestackhci.models.MarketplaceGalleryImages] - :keyword next_link: - :paramtype next_link: str + :keyword catalog_plan_id: Identifier of the CatalogPlan for the sku. + :paramtype catalog_plan_id: str + :keyword marketplace_sku_id: Identifier for the sku. + :paramtype marketplace_sku_id: str + :keyword marketplace_sku_versions: Array of SKU versions available. + :paramtype marketplace_sku_versions: list[str] """ super().__init__(**kwargs) - self.value = value - self.next_link = next_link + self.catalog_plan_id = catalog_plan_id + self.marketplace_sku_id = marketplace_sku_id + self.marketplace_sku_versions = marketplace_sku_versions -class MarketplaceGalleryImageStatus(_serialization.Model): - """The observed state of marketplace gallery images. +class SoftwareAssuranceChangeRequest(_serialization.Model): + """SoftwareAssuranceChangeRequest. - :ivar error_code: MarketplaceGalleryImage provisioning error code. - :vartype error_code: str - :ivar error_message: Descriptive error message. - :vartype error_message: str - :ivar provisioning_status: - :vartype provisioning_status: - ~azure.mgmt.azurestackhci.models.MarketplaceGalleryImageStatusProvisioningStatus - :ivar download_status: The download status of the gallery image. - :vartype download_status: - ~azure.mgmt.azurestackhci.models.MarketplaceGalleryImageStatusDownloadStatus - :ivar progress_percentage: The progress of the operation in percentage. - :vartype progress_percentage: int + :ivar properties: + :vartype properties: ~azure.mgmt.azurestackhci.models.SoftwareAssuranceChangeRequestProperties """ _attribute_map = { - "error_code": {"key": "errorCode", "type": "str"}, - "error_message": {"key": "errorMessage", "type": "str"}, - "provisioning_status": {"key": "provisioningStatus", "type": "MarketplaceGalleryImageStatusProvisioningStatus"}, - "download_status": {"key": "downloadStatus", "type": "MarketplaceGalleryImageStatusDownloadStatus"}, - "progress_percentage": {"key": "progressPercentage", "type": "int"}, + "properties": {"key": "properties", "type": "SoftwareAssuranceChangeRequestProperties"}, + } + + def __init__( + self, *, properties: Optional["_models.SoftwareAssuranceChangeRequestProperties"] = None, **kwargs: Any + ) -> None: + """ + :keyword properties: + :paramtype properties: + ~azure.mgmt.azurestackhci.models.SoftwareAssuranceChangeRequestProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class SoftwareAssuranceChangeRequestProperties(_serialization.Model): + """SoftwareAssuranceChangeRequestProperties. + + :ivar software_assurance_intent: Customer Intent for Software Assurance Benefit. Known values + are: "Enable" and "Disable". + :vartype software_assurance_intent: str or + ~azure.mgmt.azurestackhci.models.SoftwareAssuranceIntent + """ + + _attribute_map = { + "software_assurance_intent": {"key": "softwareAssuranceIntent", "type": "str"}, } def __init__( self, *, - error_code: Optional[str] = None, - error_message: Optional[str] = None, - provisioning_status: Optional["_models.MarketplaceGalleryImageStatusProvisioningStatus"] = None, - download_status: Optional["_models.MarketplaceGalleryImageStatusDownloadStatus"] = None, - progress_percentage: Optional[int] = None, + software_assurance_intent: Optional[Union[str, "_models.SoftwareAssuranceIntent"]] = None, **kwargs: Any ) -> None: """ - :keyword error_code: MarketplaceGalleryImage provisioning error code. - :paramtype error_code: str - :keyword error_message: Descriptive error message. - :paramtype error_message: str - :keyword provisioning_status: - :paramtype provisioning_status: - ~azure.mgmt.azurestackhci.models.MarketplaceGalleryImageStatusProvisioningStatus - :keyword download_status: The download status of the gallery image. - :paramtype download_status: - ~azure.mgmt.azurestackhci.models.MarketplaceGalleryImageStatusDownloadStatus - :keyword progress_percentage: The progress of the operation in percentage. - :paramtype progress_percentage: int + :keyword software_assurance_intent: Customer Intent for Software Assurance Benefit. Known + values are: "Enable" and "Disable". + :paramtype software_assurance_intent: str or + ~azure.mgmt.azurestackhci.models.SoftwareAssuranceIntent """ super().__init__(**kwargs) - self.error_code = error_code - self.error_message = error_message - self.provisioning_status = provisioning_status - self.download_status = download_status - self.progress_percentage = progress_percentage + self.software_assurance_intent = software_assurance_intent -class MarketplaceGalleryImageStatusDownloadStatus(_serialization.Model): - """The download status of the gallery image. +class SoftwareAssuranceProperties(_serialization.Model): + """Software Assurance properties of the cluster. - :ivar download_size_in_mb: The downloaded sized of the image in MB. - :vartype download_size_in_mb: int + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar software_assurance_status: Status of the Software Assurance for the cluster. Known values + are: "Enabled" and "Disabled". + :vartype software_assurance_status: str or + ~azure.mgmt.azurestackhci.models.SoftwareAssuranceStatus + :ivar software_assurance_intent: Customer Intent for Software Assurance Benefit. Known values + are: "Enable" and "Disable". + :vartype software_assurance_intent: str or + ~azure.mgmt.azurestackhci.models.SoftwareAssuranceIntent + :ivar last_updated: TimeStamp denoting the latest SA benefit applicability is validated. + :vartype last_updated: ~datetime.datetime """ + _validation = { + "software_assurance_status": {"readonly": True}, + "last_updated": {"readonly": True}, + } + _attribute_map = { - "download_size_in_mb": {"key": "downloadSizeInMB", "type": "int"}, + "software_assurance_status": {"key": "softwareAssuranceStatus", "type": "str"}, + "software_assurance_intent": {"key": "softwareAssuranceIntent", "type": "str"}, + "last_updated": {"key": "lastUpdated", "type": "iso-8601"}, } - def __init__(self, *, download_size_in_mb: Optional[int] = None, **kwargs: Any) -> None: + def __init__( + self, + *, + software_assurance_intent: Optional[Union[str, "_models.SoftwareAssuranceIntent"]] = None, + **kwargs: Any + ) -> None: """ - :keyword download_size_in_mb: The downloaded sized of the image in MB. - :paramtype download_size_in_mb: int + :keyword software_assurance_intent: Customer Intent for Software Assurance Benefit. Known + values are: "Enable" and "Disable". + :paramtype software_assurance_intent: str or + ~azure.mgmt.azurestackhci.models.SoftwareAssuranceIntent """ super().__init__(**kwargs) - self.download_size_in_mb = download_size_in_mb + self.software_assurance_status = None + self.software_assurance_intent = software_assurance_intent + self.last_updated = None -class MarketplaceGalleryImageStatusProvisioningStatus(_serialization.Model): - """MarketplaceGalleryImageStatusProvisioningStatus. +class SshConfiguration(_serialization.Model): + """SSH configuration for Linux based VMs running on Azure. - :ivar operation_id: The ID of the operation performed on the gallery image. - :vartype operation_id: str - :ivar status: The status of the operation performed on the gallery image [Succeeded, Failed, - InProgress]. Known values are: "Succeeded", "Failed", and "InProgress". - :vartype status: str or ~azure.mgmt.azurestackhci.models.Status + :ivar public_keys: The list of SSH public keys used to authenticate with linux based VMs. + :vartype public_keys: list[~azure.mgmt.azurestackhci.models.SshPublicKey] """ _attribute_map = { - "operation_id": {"key": "operationId", "type": "str"}, + "public_keys": {"key": "publicKeys", "type": "[SshPublicKey]"}, + } + + def __init__(self, *, public_keys: Optional[List["_models.SshPublicKey"]] = None, **kwargs: Any) -> None: + """ + :keyword public_keys: The list of SSH public keys used to authenticate with linux based VMs. + :paramtype public_keys: list[~azure.mgmt.azurestackhci.models.SshPublicKey] + """ + super().__init__(**kwargs) + self.public_keys = public_keys + + +class SshPublicKey(_serialization.Model): + """Contains information about SSH certificate public key and the path on the Linux VM where the + public key is placed. + + :ivar path: Specifies the full path on the created VM where ssh public key is stored. If the + file already exists, the specified key is appended to the file. Example: + /home/user/.ssh/authorized_keys. + :vartype path: str + :ivar key_data: SSH public key certificate used to authenticate with the VM through ssh. The + key needs to be at least 2048-bit and in ssh-rsa format. :code:`
`:code:`
` For creating + ssh keys, see [Create SSH keys on Linux and Mac for Linux VMs in + Azure]https://docs.microsoft.com/azure/virtual-machines/linux/create-ssh-keys-detailed). + :vartype key_data: str + """ + + _attribute_map = { + "path": {"key": "path", "type": "str"}, + "key_data": {"key": "keyData", "type": "str"}, + } + + def __init__(self, *, path: Optional[str] = None, key_data: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword path: Specifies the full path on the created VM where ssh public key is stored. If the + file already exists, the specified key is appended to the file. Example: + /home/user/.ssh/authorized_keys. + :paramtype path: str + :keyword key_data: SSH public key certificate used to authenticate with the VM through ssh. The + key needs to be at least 2048-bit and in ssh-rsa format. :code:`
`:code:`
` For creating + ssh keys, see [Create SSH keys on Linux and Mac for Linux VMs in + Azure]https://docs.microsoft.com/azure/virtual-machines/linux/create-ssh-keys-detailed). + :paramtype key_data: str + """ + super().__init__(**kwargs) + self.path = path + self.key_data = key_data + + +class Step(_serialization.Model): + """Progress representation of the update run steps. + + :ivar name: Name of the step. + :vartype name: str + :ivar description: More detailed description of the step. + :vartype description: str + :ivar error_message: Error message, specified if the step is in a failed state. + :vartype error_message: str + :ivar status: Status of the step, bubbled up from the ECE action plan for installation + attempts. Values are: 'Success', 'Error', 'InProgress', and 'Unknown status'. + :vartype status: str + :ivar start_time_utc: When the step started, or empty if it has not started executing. + :vartype start_time_utc: ~datetime.datetime + :ivar end_time_utc: When the step reached a terminal state. + :vartype end_time_utc: ~datetime.datetime + :ivar last_updated_time_utc: Completion time of this step or the last completed sub-step. + :vartype last_updated_time_utc: ~datetime.datetime + :ivar steps: Recursive model for child steps of this step. + :vartype steps: list[~azure.mgmt.azurestackhci.models.Step] + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "error_message": {"key": "errorMessage", "type": "str"}, "status": {"key": "status", "type": "str"}, + "start_time_utc": {"key": "startTimeUtc", "type": "iso-8601"}, + "end_time_utc": {"key": "endTimeUtc", "type": "iso-8601"}, + "last_updated_time_utc": {"key": "lastUpdatedTimeUtc", "type": "iso-8601"}, + "steps": {"key": "steps", "type": "[Step]"}, } def __init__( self, *, - operation_id: Optional[str] = None, - status: Optional[Union[str, "_models.Status"]] = None, + name: Optional[str] = None, + description: Optional[str] = None, + error_message: Optional[str] = None, + status: Optional[str] = None, + start_time_utc: Optional[datetime.datetime] = None, + end_time_utc: Optional[datetime.datetime] = None, + last_updated_time_utc: Optional[datetime.datetime] = None, + steps: Optional[List["_models.Step"]] = None, **kwargs: Any ) -> None: """ - :keyword operation_id: The ID of the operation performed on the gallery image. - :paramtype operation_id: str - :keyword status: The status of the operation performed on the gallery image [Succeeded, Failed, - InProgress]. Known values are: "Succeeded", "Failed", and "InProgress". - :paramtype status: str or ~azure.mgmt.azurestackhci.models.Status + :keyword name: Name of the step. + :paramtype name: str + :keyword description: More detailed description of the step. + :paramtype description: str + :keyword error_message: Error message, specified if the step is in a failed state. + :paramtype error_message: str + :keyword status: Status of the step, bubbled up from the ECE action plan for installation + attempts. Values are: 'Success', 'Error', 'InProgress', and 'Unknown status'. + :paramtype status: str + :keyword start_time_utc: When the step started, or empty if it has not started executing. + :paramtype start_time_utc: ~datetime.datetime + :keyword end_time_utc: When the step reached a terminal state. + :paramtype end_time_utc: ~datetime.datetime + :keyword last_updated_time_utc: Completion time of this step or the last completed sub-step. + :paramtype last_updated_time_utc: ~datetime.datetime + :keyword steps: Recursive model for child steps of this step. + :paramtype steps: list[~azure.mgmt.azurestackhci.models.Step] """ super().__init__(**kwargs) - self.operation_id = operation_id + self.name = name + self.description = description + self.error_message = error_message self.status = status + self.start_time_utc = start_time_utc + self.end_time_utc = end_time_utc + self.last_updated_time_utc = last_updated_time_utc + self.steps = steps -class MarketplaceGalleryImagesUpdateRequest(_serialization.Model): - """The marketplace gallery image resource patch definition. +class Storage(_serialization.Model): + """The Storage config of AzureStackHCI Cluster. - :ivar tags: Resource tags. - :vartype tags: dict[str, str] + :ivar configuration_mode: By default, this mode is set to Express and your storage is + configured as per best practices based on the number of nodes in the cluster. Allowed values + are 'Express','InfraOnly', 'KeepStorage'. + :vartype configuration_mode: str """ _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, + "configuration_mode": {"key": "configurationMode", "type": "str"}, } - def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + def __init__(self, *, configuration_mode: str = "Express", **kwargs: Any) -> None: """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] + :keyword configuration_mode: By default, this mode is set to Express and your storage is + configured as per best practices based on the number of nodes in the cluster. Allowed values + are 'Express','InfraOnly', 'KeepStorage'. + :paramtype configuration_mode: str """ super().__init__(**kwargs) - self.tags = tags + self.configuration_mode = configuration_mode -class NetworkInterfaces(TrackedResource): # pylint: disable=too-many-instance-attributes - """The network interface resource definition. +class StorageContainers(TrackedResource): + """The storage container resource 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. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -1921,18 +6132,13 @@ class NetworkInterfaces(TrackedResource): # pylint: disable=too-many-instance-a :vartype location: str :ivar extended_location: The extendedLocation of the resource. :vartype extended_location: ~azure.mgmt.azurestackhci.models.ExtendedLocation - :ivar ip_configurations: IPConfigurations - A list of IPConfigurations of the network - interface. - :vartype ip_configurations: list[~azure.mgmt.azurestackhci.models.IPConfiguration] - :ivar mac_address: MacAddress - The MAC address of the network interface. - :vartype mac_address: str - :ivar dns_settings: DNS Settings for the interface. - :vartype dns_settings: ~azure.mgmt.azurestackhci.models.InterfaceDNSSettings - :ivar provisioning_state: Provisioning state of the network interface. Known values are: + :ivar path: Path of the storage container on the disk. + :vartype path: str + :ivar provisioning_state: Provisioning state of the storage container. Known values are: "Succeeded", "Failed", "InProgress", "Accepted", "Deleting", and "Canceled". :vartype provisioning_state: str or ~azure.mgmt.azurestackhci.models.ProvisioningStateEnum - :ivar status: The observed state of network interfaces. - :vartype status: ~azure.mgmt.azurestackhci.models.NetworkInterfaceStatus + :ivar status: The observed state of storage containers. + :vartype status: ~azure.mgmt.azurestackhci.models.StorageContainerStatus """ _validation = { @@ -1953,11 +6159,9 @@ class NetworkInterfaces(TrackedResource): # pylint: disable=too-many-instance-a "tags": {"key": "tags", "type": "{str}"}, "location": {"key": "location", "type": "str"}, "extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"}, - "ip_configurations": {"key": "properties.ipConfigurations", "type": "[IPConfiguration]"}, - "mac_address": {"key": "properties.macAddress", "type": "str"}, - "dns_settings": {"key": "properties.dnsSettings", "type": "InterfaceDNSSettings"}, + "path": {"key": "properties.path", "type": "str"}, "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "status": {"key": "properties.status", "type": "NetworkInterfaceStatus"}, + "status": {"key": "properties.status", "type": "StorageContainerStatus"}, } def __init__( @@ -1966,9 +6170,7 @@ def __init__( location: str, tags: Optional[Dict[str, str]] = None, extended_location: Optional["_models.ExtendedLocation"] = None, - ip_configurations: Optional[List["_models.IPConfiguration"]] = None, - mac_address: Optional[str] = None, - dns_settings: Optional["_models.InterfaceDNSSettings"] = None, + path: Optional[str] = None, **kwargs: Any ) -> None: """ @@ -1978,47 +6180,40 @@ def __init__( :paramtype location: str :keyword extended_location: The extendedLocation of the resource. :paramtype extended_location: ~azure.mgmt.azurestackhci.models.ExtendedLocation - :keyword ip_configurations: IPConfigurations - A list of IPConfigurations of the network - interface. - :paramtype ip_configurations: list[~azure.mgmt.azurestackhci.models.IPConfiguration] - :keyword mac_address: MacAddress - The MAC address of the network interface. - :paramtype mac_address: str - :keyword dns_settings: DNS Settings for the interface. - :paramtype dns_settings: ~azure.mgmt.azurestackhci.models.InterfaceDNSSettings + :keyword path: Path of the storage container on the disk. + :paramtype path: str """ super().__init__(tags=tags, location=location, **kwargs) self.extended_location = extended_location - self.ip_configurations = ip_configurations - self.mac_address = mac_address - self.dns_settings = dns_settings + self.path = path self.provisioning_state = None self.status = None -class NetworkInterfacesListResult(_serialization.Model): - """NetworkInterfacesListResult. +class StorageContainersListResult(_serialization.Model): + """StorageContainersListResult. :ivar value: - :vartype value: list[~azure.mgmt.azurestackhci.models.NetworkInterfaces] + :vartype value: list[~azure.mgmt.azurestackhci.models.StorageContainers] :ivar next_link: :vartype next_link: str """ _attribute_map = { - "value": {"key": "value", "type": "[NetworkInterfaces]"}, + "value": {"key": "value", "type": "[StorageContainers]"}, "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["_models.NetworkInterfaces"]] = None, + value: Optional[List["_models.StorageContainers"]] = None, next_link: Optional[str] = None, **kwargs: Any ) -> None: """ :keyword value: - :paramtype value: list[~azure.mgmt.azurestackhci.models.NetworkInterfaces] + :paramtype value: list[~azure.mgmt.azurestackhci.models.StorageContainers] :keyword next_link: :paramtype next_link: str """ @@ -2027,22 +6222,28 @@ def __init__( self.next_link = next_link -class NetworkInterfaceStatus(_serialization.Model): - """The observed state of network interfaces. +class StorageContainerStatus(_serialization.Model): + """The observed state of storage containers. - :ivar error_code: NetworkInterface provisioning error code. + :ivar error_code: StorageContainer provisioning error code. :vartype error_code: str :ivar error_message: Descriptive error message. :vartype error_message: str + :ivar available_size_mb: Amount of space available on the disk in MB. + :vartype available_size_mb: int + :ivar container_size_mb: Total size of the disk in MB. + :vartype container_size_mb: int :ivar provisioning_status: :vartype provisioning_status: - ~azure.mgmt.azurestackhci.models.NetworkInterfaceStatusProvisioningStatus + ~azure.mgmt.azurestackhci.models.StorageContainerStatusProvisioningStatus """ _attribute_map = { "error_code": {"key": "errorCode", "type": "str"}, "error_message": {"key": "errorMessage", "type": "str"}, - "provisioning_status": {"key": "provisioningStatus", "type": "NetworkInterfaceStatusProvisioningStatus"}, + "available_size_mb": {"key": "availableSizeMB", "type": "int"}, + "container_size_mb": {"key": "containerSizeMB", "type": "int"}, + "provisioning_status": {"key": "provisioningStatus", "type": "StorageContainerStatusProvisioningStatus"}, } def __init__( @@ -2050,31 +6251,42 @@ def __init__( *, error_code: Optional[str] = None, error_message: Optional[str] = None, - provisioning_status: Optional["_models.NetworkInterfaceStatusProvisioningStatus"] = None, + available_size_mb: Optional[int] = None, + container_size_mb: Optional[int] = None, + provisioning_status: Optional["_models.StorageContainerStatusProvisioningStatus"] = None, **kwargs: Any ) -> None: """ - :keyword error_code: NetworkInterface provisioning error code. + :keyword error_code: StorageContainer provisioning error code. :paramtype error_code: str :keyword error_message: Descriptive error message. :paramtype error_message: str + :keyword available_size_mb: Amount of space available on the disk in MB. + :paramtype available_size_mb: int + :keyword container_size_mb: Total size of the disk in MB. + :paramtype container_size_mb: int :keyword provisioning_status: :paramtype provisioning_status: - ~azure.mgmt.azurestackhci.models.NetworkInterfaceStatusProvisioningStatus + ~azure.mgmt.azurestackhci.models.StorageContainerStatusProvisioningStatus """ super().__init__(**kwargs) self.error_code = error_code self.error_message = error_message + self.available_size_mb = available_size_mb + self.container_size_mb = container_size_mb self.provisioning_status = provisioning_status -class NetworkInterfaceStatusProvisioningStatus(_serialization.Model): - """NetworkInterfaceStatusProvisioningStatus. +class StorageContainerStatusProvisioningStatus(_serialization.Model): + """StorageContainerStatusProvisioningStatus. - :ivar operation_id: The ID of the operation performed on the network interface. + :ivar operation_id: The ID of the operation performed on the storage container. :vartype operation_id: str - :ivar status: The status of the operation performed on the network interface [Succeeded, - Failed, InProgress]. Known values are: "Succeeded", "Failed", and "InProgress". + :ivar status: The status of the operation performed on the storage container [Succeeded, + Failed, InProgress]. Known values are: "NotYetRegistered", "ConnectedRecently", + "NotConnectedRecently", "Disconnected", "Error", "NotSpecified", "ValidationInProgress", + "ValidationSuccess", "ValidationFailed", "DeploymentInProgress", "DeploymentFailed", + "DeploymentSuccess", "Succeeded", "Failed", and "InProgress". :vartype status: str or ~azure.mgmt.azurestackhci.models.Status """ @@ -2091,10 +6303,13 @@ def __init__( **kwargs: Any ) -> None: """ - :keyword operation_id: The ID of the operation performed on the network interface. + :keyword operation_id: The ID of the operation performed on the storage container. :paramtype operation_id: str - :keyword status: The status of the operation performed on the network interface [Succeeded, - Failed, InProgress]. Known values are: "Succeeded", "Failed", and "InProgress". + :keyword status: The status of the operation performed on the storage container [Succeeded, + Failed, InProgress]. Known values are: "NotYetRegistered", "ConnectedRecently", + "NotConnectedRecently", "Disconnected", "Error", "NotSpecified", "ValidationInProgress", + "ValidationSuccess", "ValidationFailed", "DeploymentInProgress", "DeploymentFailed", + "DeploymentSuccess", "Succeeded", "Failed", and "InProgress". :paramtype status: str or ~azure.mgmt.azurestackhci.models.Status """ super().__init__(**kwargs) @@ -2102,8 +6317,8 @@ def __init__( self.status = status -class NetworkInterfacesUpdateRequest(_serialization.Model): - """The network interface resource patch definition. +class StorageContainersUpdateRequest(_serialization.Model): + """The storage container resource patch definition. :ivar tags: Resource tags. :vartype tags: dict[str, str] @@ -2117,306 +6332,117 @@ def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> N """ :keyword tags: Resource tags. :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.tags = tags - - -class NetworkProfileUpdate(_serialization.Model): - """NetworkProfile - describes the network update configuration the virtual machine instance. - - :ivar network_interfaces: NetworkInterfaces - list of network interfaces to be attached to the - virtual machine instance. - :vartype network_interfaces: - list[~azure.mgmt.azurestackhci.models.NetworkProfileUpdateNetworkInterfacesItem] - """ - - _attribute_map = { - "network_interfaces": {"key": "networkInterfaces", "type": "[NetworkProfileUpdateNetworkInterfacesItem]"}, - } - - def __init__( - self, - *, - network_interfaces: Optional[List["_models.NetworkProfileUpdateNetworkInterfacesItem"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword network_interfaces: NetworkInterfaces - list of network interfaces to be attached to - the virtual machine instance. - :paramtype network_interfaces: - list[~azure.mgmt.azurestackhci.models.NetworkProfileUpdateNetworkInterfacesItem] - """ - super().__init__(**kwargs) - self.network_interfaces = network_interfaces - - -class NetworkProfileUpdateNetworkInterfacesItem(_serialization.Model): - """NetworkProfileUpdateNetworkInterfacesItem. - - :ivar id: ID - Resource ID of the network interface. - :vartype id: str - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - } - - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: ID - Resource ID of the network interface. - :paramtype id: str - """ - super().__init__(**kwargs) - self.id = id - - -class Operation(_serialization.Model): - """Details of a REST API operation, returned from the Resource Provider Operations API. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: - "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". - :vartype name: str - :ivar is_data_action: Whether the operation applies to data-plane. This is "true" for - data-plane operations and "false" for ARM/control-plane operations. - :vartype is_data_action: bool - :ivar display: Localized display information for this particular operation. - :vartype display: ~azure.mgmt.azurestackhci.models.OperationDisplay - :ivar origin: The intended executor of the operation; as in Resource Based Access Control - (RBAC) and audit logs UX. Default value is "user,system". Known values are: "user", "system", - and "user,system". - :vartype origin: str or ~azure.mgmt.azurestackhci.models.Origin - :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for - internal only APIs. "Internal" - :vartype action_type: str or ~azure.mgmt.azurestackhci.models.ActionType - """ - - _validation = { - "name": {"readonly": True}, - "is_data_action": {"readonly": True}, - "origin": {"readonly": True}, - "action_type": {"readonly": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "is_data_action": {"key": "isDataAction", "type": "bool"}, - "display": {"key": "display", "type": "OperationDisplay"}, - "origin": {"key": "origin", "type": "str"}, - "action_type": {"key": "actionType", "type": "str"}, - } - - def __init__(self, *, display: Optional["_models.OperationDisplay"] = None, **kwargs: Any) -> None: - """ - :keyword display: Localized display information for this particular operation. - :paramtype display: ~azure.mgmt.azurestackhci.models.OperationDisplay - """ - super().__init__(**kwargs) - self.name = None - self.is_data_action = None - self.display = display - self.origin = None - self.action_type = None - - -class OperationDisplay(_serialization.Model): - """Localized display information for this particular operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provider: The localized friendly form of the resource provider name, e.g. "Microsoft - Monitoring Insights" or "Microsoft Compute". - :vartype provider: str - :ivar resource: The localized friendly name of the resource type related to this operation. - E.g. "Virtual Machines" or "Job Schedule Collections". - :vartype resource: str - :ivar operation: The concise, localized friendly name for the operation; suitable for - dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". - :vartype operation: str - :ivar description: The short, localized friendly description of the operation; suitable for - tool tips and detailed views. - :vartype description: str - """ - - _validation = { - "provider": {"readonly": True}, - "resource": {"readonly": True}, - "operation": {"readonly": True}, - "description": {"readonly": True}, - } - - _attribute_map = { - "provider": {"key": "provider", "type": "str"}, - "resource": {"key": "resource", "type": "str"}, - "operation": {"key": "operation", "type": "str"}, - "description": {"key": "description", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.provider = None - self.resource = None - self.operation = None - self.description = None - - -class OperationListResult(_serialization.Model): - """A list of REST API operations supported by an Azure Resource Provider. It contains an URL link - to get the next set of results. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: List of operations supported by the resource provider. - :vartype value: list[~azure.mgmt.azurestackhci.models.Operation] - :ivar next_link: URL to get the next set of operation list results (if there are any). - :vartype next_link: str - """ - - _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, - } - - _attribute_map = { - "value": {"key": "value", "type": "[Operation]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ + """ super().__init__(**kwargs) - self.value = None - self.next_link = None + self.tags = tags -class OsProfileUpdate(_serialization.Model): - """OsProfile - describes the update configuration of the operating system. +class StorageNetworks(_serialization.Model): + """The StorageNetworks of a cluster. - :ivar computer_name: ComputerName - name of the computer. - :vartype computer_name: str - :ivar linux_configuration: - :vartype linux_configuration: - ~azure.mgmt.azurestackhci.models.OsProfileUpdateLinuxConfiguration - :ivar windows_configuration: - :vartype windows_configuration: - ~azure.mgmt.azurestackhci.models.OsProfileUpdateWindowsConfiguration + :ivar name: Name of the storage network. + :vartype name: str + :ivar network_adapter_name: Name of the storage network adapter. + :vartype network_adapter_name: str + :ivar vlan_id: ID specified for the VLAN storage network. This setting is applied to the + network interfaces that route the storage and VM migration traffic. + :vartype vlan_id: str """ _attribute_map = { - "computer_name": {"key": "computerName", "type": "str"}, - "linux_configuration": {"key": "linuxConfiguration", "type": "OsProfileUpdateLinuxConfiguration"}, - "windows_configuration": {"key": "windowsConfiguration", "type": "OsProfileUpdateWindowsConfiguration"}, + "name": {"key": "name", "type": "str"}, + "network_adapter_name": {"key": "networkAdapterName", "type": "str"}, + "vlan_id": {"key": "vlanId", "type": "str"}, } def __init__( self, *, - computer_name: Optional[str] = None, - linux_configuration: Optional["_models.OsProfileUpdateLinuxConfiguration"] = None, - windows_configuration: Optional["_models.OsProfileUpdateWindowsConfiguration"] = None, + name: Optional[str] = None, + network_adapter_name: Optional[str] = None, + vlan_id: Optional[str] = None, **kwargs: Any ) -> None: """ - :keyword computer_name: ComputerName - name of the computer. - :paramtype computer_name: str - :keyword linux_configuration: - :paramtype linux_configuration: - ~azure.mgmt.azurestackhci.models.OsProfileUpdateLinuxConfiguration - :keyword windows_configuration: - :paramtype windows_configuration: - ~azure.mgmt.azurestackhci.models.OsProfileUpdateWindowsConfiguration + :keyword name: Name of the storage network. + :paramtype name: str + :keyword network_adapter_name: Name of the storage network adapter. + :paramtype network_adapter_name: str + :keyword vlan_id: ID specified for the VLAN storage network. This setting is applied to the + network interfaces that route the storage and VM migration traffic. + :paramtype vlan_id: str """ super().__init__(**kwargs) - self.computer_name = computer_name - self.linux_configuration = linux_configuration - self.windows_configuration = windows_configuration + self.name = name + self.network_adapter_name = network_adapter_name + self.vlan_id = vlan_id -class OsProfileUpdateLinuxConfiguration(_serialization.Model): - """OsProfileUpdateLinuxConfiguration. +class StorageProfileUpdate(_serialization.Model): + """StorageProfileUpdate. - :ivar provision_vm_agent: Used to indicate whether Arc for Servers agent onboarding should be - triggered during the virtual machine instance creation process. - :vartype provision_vm_agent: bool - :ivar provision_vm_config_agent: Used to indicate whether the VM Config Agent should be - installed during the virtual machine creation process. - :vartype provision_vm_config_agent: bool + :ivar data_disks: adds data disks to the virtual machine instance for the update call. + :vartype data_disks: list[~azure.mgmt.azurestackhci.models.StorageProfileUpdateDataDisksItem] """ _attribute_map = { - "provision_vm_agent": {"key": "provisionVMAgent", "type": "bool"}, - "provision_vm_config_agent": {"key": "provisionVMConfigAgent", "type": "bool"}, + "data_disks": {"key": "dataDisks", "type": "[StorageProfileUpdateDataDisksItem]"}, } def __init__( - self, - *, - provision_vm_agent: Optional[bool] = None, - provision_vm_config_agent: Optional[bool] = None, - **kwargs: Any + self, *, data_disks: Optional[List["_models.StorageProfileUpdateDataDisksItem"]] = None, **kwargs: Any ) -> None: """ - :keyword provision_vm_agent: Used to indicate whether Arc for Servers agent onboarding should - be triggered during the virtual machine instance creation process. - :paramtype provision_vm_agent: bool - :keyword provision_vm_config_agent: Used to indicate whether the VM Config Agent should be - installed during the virtual machine creation process. - :paramtype provision_vm_config_agent: bool + :keyword data_disks: adds data disks to the virtual machine instance for the update call. + :paramtype data_disks: list[~azure.mgmt.azurestackhci.models.StorageProfileUpdateDataDisksItem] """ super().__init__(**kwargs) - self.provision_vm_agent = provision_vm_agent - self.provision_vm_config_agent = provision_vm_config_agent + self.data_disks = data_disks -class OsProfileUpdateWindowsConfiguration(_serialization.Model): - """OsProfileUpdateWindowsConfiguration. +class StorageProfileUpdateDataDisksItem(_serialization.Model): + """StorageProfileUpdateDataDisksItem. - :ivar provision_vm_agent: Used to indicate whether Arc for Servers agent onboarding should be - triggered during the virtual machine instance creation process. - :vartype provision_vm_agent: bool - :ivar provision_vm_config_agent: Used to indicate whether the VM Config Agent should be - installed during the virtual machine creation process. - :vartype provision_vm_config_agent: bool + :ivar id: + :vartype id: str """ _attribute_map = { - "provision_vm_agent": {"key": "provisionVMAgent", "type": "bool"}, - "provision_vm_config_agent": {"key": "provisionVMConfigAgent", "type": "bool"}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - provision_vm_agent: Optional[bool] = None, - provision_vm_config_agent: Optional[bool] = None, - **kwargs: Any - ) -> None: + def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin """ - :keyword provision_vm_agent: Used to indicate whether Arc for Servers agent onboarding should - be triggered during the virtual machine instance creation process. - :paramtype provision_vm_agent: bool - :keyword provision_vm_config_agent: Used to indicate whether the VM Config Agent should be - installed during the virtual machine creation process. - :paramtype provision_vm_config_agent: bool + :keyword id: + :paramtype id: str """ super().__init__(**kwargs) - self.provision_vm_agent = provision_vm_agent - self.provision_vm_config_agent = provision_vm_config_agent + self.id = id -class Route(_serialization.Model): - """Route - Route resource. +class Subnet(_serialization.Model): + """Subnet. - :ivar name: Name - name of the subnet. + :ivar name: Name - The name of the resource that is unique within a resource group. This name + can be used to access the resource. :vartype name: str - :ivar address_prefix: The destination CIDR to which the route applies. + :ivar address_prefix: The address prefix for the subnet: Cidr for this subnet - IPv4, IPv6. :vartype address_prefix: str - :ivar next_hop_ip_address: The IP address packets should be forwarded to. Next hop values are - only allowed in routes where the next hop type is VirtualAppliance. - :vartype next_hop_ip_address: str + :ivar address_prefixes: List of address prefixes for the subnet. + :vartype address_prefixes: list[str] + :ivar ip_allocation_method: IPAllocationMethod - The IP address allocation method. Possible + values include: 'Static', 'Dynamic'. Known values are: "Dynamic" and "Static". + :vartype ip_allocation_method: str or ~azure.mgmt.azurestackhci.models.IpAllocationMethodEnum + :ivar ip_configuration_references: IPConfigurationReferences - list of + IPConfigurationReferences. + :vartype ip_configuration_references: + list[~azure.mgmt.azurestackhci.models.SubnetPropertiesFormatIpConfigurationReferencesItem] + :ivar route_table: Route table resource. + :vartype route_table: ~azure.mgmt.azurestackhci.models.RouteTable + :ivar ip_pools: network associated pool of IP Addresses. + :vartype ip_pools: list[~azure.mgmt.azurestackhci.models.IPPool] + :ivar vlan: Vlan to use for the subnet. + :vartype vlan: int """ _validation = { @@ -2426,7 +6452,15 @@ class Route(_serialization.Model): _attribute_map = { "name": {"key": "name", "type": "str"}, "address_prefix": {"key": "properties.addressPrefix", "type": "str"}, - "next_hop_ip_address": {"key": "properties.nextHopIpAddress", "type": "str"}, + "address_prefixes": {"key": "properties.addressPrefixes", "type": "[str]"}, + "ip_allocation_method": {"key": "properties.ipAllocationMethod", "type": "str"}, + "ip_configuration_references": { + "key": "properties.ipConfigurationReferences", + "type": "[SubnetPropertiesFormatIpConfigurationReferencesItem]", + }, + "route_table": {"key": "properties.routeTable", "type": "RouteTable"}, + "ip_pools": {"key": "properties.ipPools", "type": "[IPPool]"}, + "vlan": {"key": "properties.vlan", "type": "int"}, } def __init__( @@ -2434,130 +6468,436 @@ def __init__( *, name: Optional[str] = None, address_prefix: Optional[str] = None, - next_hop_ip_address: Optional[str] = None, + address_prefixes: Optional[List[str]] = None, + ip_allocation_method: Optional[Union[str, "_models.IpAllocationMethodEnum"]] = None, + ip_configuration_references: Optional[ + List["_models.SubnetPropertiesFormatIpConfigurationReferencesItem"] + ] = None, + route_table: Optional["_models.RouteTable"] = None, + ip_pools: Optional[List["_models.IPPool"]] = None, + vlan: Optional[int] = None, **kwargs: Any ) -> None: """ - :keyword name: Name - name of the subnet. + :keyword name: Name - The name of the resource that is unique within a resource group. This + name can be used to access the resource. :paramtype name: str - :keyword address_prefix: The destination CIDR to which the route applies. + :keyword address_prefix: The address prefix for the subnet: Cidr for this subnet - IPv4, IPv6. :paramtype address_prefix: str - :keyword next_hop_ip_address: The IP address packets should be forwarded to. Next hop values - are only allowed in routes where the next hop type is VirtualAppliance. - :paramtype next_hop_ip_address: str + :keyword address_prefixes: List of address prefixes for the subnet. + :paramtype address_prefixes: list[str] + :keyword ip_allocation_method: IPAllocationMethod - The IP address allocation method. Possible + values include: 'Static', 'Dynamic'. Known values are: "Dynamic" and "Static". + :paramtype ip_allocation_method: str or ~azure.mgmt.azurestackhci.models.IpAllocationMethodEnum + :keyword ip_configuration_references: IPConfigurationReferences - list of + IPConfigurationReferences. + :paramtype ip_configuration_references: + list[~azure.mgmt.azurestackhci.models.SubnetPropertiesFormatIpConfigurationReferencesItem] + :keyword route_table: Route table resource. + :paramtype route_table: ~azure.mgmt.azurestackhci.models.RouteTable + :keyword ip_pools: network associated pool of IP Addresses. + :paramtype ip_pools: list[~azure.mgmt.azurestackhci.models.IPPool] + :keyword vlan: Vlan to use for the subnet. + :paramtype vlan: int + """ + super().__init__(**kwargs) + self.name = name + self.address_prefix = address_prefix + self.address_prefixes = address_prefixes + self.ip_allocation_method = ip_allocation_method + self.ip_configuration_references = ip_configuration_references + self.route_table = route_table + self.ip_pools = ip_pools + self.vlan = vlan + + +class SubnetPropertiesFormatIpConfigurationReferencesItem(_serialization.Model): # pylint: disable=name-too-long + """IPConfigurationReference - Describes a IPConfiguration under the virtual network. + + :ivar id: IPConfigurationID. + :vartype id: str + """ + + _attribute_map = { + "id": {"key": "ID", "type": "str"}, + } + + def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin + """ + :keyword id: IPConfigurationID. + :paramtype id: str + """ + super().__init__(**kwargs) + self.id = id + + +class SystemData(_serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :vartype created_by_type: str or ~azure.mgmt.azurestackhci.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". + :vartype last_modified_by_type: str or ~azure.mgmt.azurestackhci.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + "created_by": {"key": "createdBy", "type": "str"}, + "created_by_type": {"key": "createdByType", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, + "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :paramtype created_by_type: str or ~azure.mgmt.azurestackhci.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". + :paramtype last_modified_by_type: str or ~azure.mgmt.azurestackhci.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime """ super().__init__(**kwargs) - self.name = name - self.address_prefix = address_prefix - self.next_hop_ip_address = next_hop_ip_address + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at -class RouteTable(_serialization.Model): - """Route table resource. +class Update(ProxyResource): # pylint: disable=too-many-instance-attributes + """Update details. Variables are only populated by the server, and will be ignored when sending a request. - :ivar etag: A unique read-only string that changes whenever the resource is updated. - :vartype etag: str - :ivar name: Resource name. + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar routes: Collection of routes contained within a route table. - :vartype routes: list[~azure.mgmt.azurestackhci.models.Route] + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.azurestackhci.models.SystemData + :ivar location: The geo-location where the resource lives. + :vartype location: str + :ivar provisioning_state: Provisioning state of the Updates proxy resource. Known values are: + "NotSpecified", "Error", "Succeeded", "Failed", "Canceled", "Connected", "Disconnected", + "Deleted", "Creating", "Updating", "Deleting", "Moving", "PartiallySucceeded", + "PartiallyConnected", "InProgress", "Accepted", "Provisioning", and "DisableInProgress". + :vartype provisioning_state: str or ~azure.mgmt.azurestackhci.models.ProvisioningState + :ivar installed_date: Date that the update was installed. + :vartype installed_date: ~datetime.datetime + :ivar description: Description of the update. + :vartype description: str + :ivar state: State of the update as it relates to this stamp. Known values are: + "HasPrerequisite", "Obsolete", "Ready", "NotApplicableBecauseAnotherUpdateIsInProgress", + "Preparing", "Installing", "Installed", "PreparationFailed", "InstallationFailed", "Invalid", + "Recalled", "Downloading", "DownloadFailed", "HealthChecking", "HealthCheckFailed", + "ReadyToInstall", "ScanInProgress", "ScanFailed", and "AdditionalContentRequired". + :vartype state: str or ~azure.mgmt.azurestackhci.models.State + :ivar prerequisites: If update State is HasPrerequisite, this property contains an array of + objects describing prerequisite updates before installing this update. Otherwise, it is empty. + :vartype prerequisites: list[~azure.mgmt.azurestackhci.models.UpdatePrerequisite] + :ivar component_versions: An array of component versions for a Solution Bundle update, and an + empty array otherwise. + :vartype component_versions: list[~azure.mgmt.azurestackhci.models.PackageVersionInfo] + :ivar reboot_required: Known values are: "Unknown", "True", and "False". + :vartype reboot_required: str or ~azure.mgmt.azurestackhci.models.RebootRequirement + :ivar health_state: Overall health state for update-specific health checks. Known values are: + "Unknown", "Success", "Failure", "Warning", "Error", and "InProgress". + :vartype health_state: str or ~azure.mgmt.azurestackhci.models.HealthState + :ivar health_check_result: An array of PrecheckResult objects. + :vartype health_check_result: list[~azure.mgmt.azurestackhci.models.PrecheckResult] + :ivar health_check_date: Last time the package-specific checks were run. + :vartype health_check_date: ~datetime.datetime + :ivar package_path: Path where the update package is available. + :vartype package_path: str + :ivar package_size_in_mb: Size of the package. This value is a combination of the size from + update metadata and size of the payload that results from the live scan operation for OS update + content. + :vartype package_size_in_mb: float + :ivar display_name: Display name of the Update. + :vartype display_name: str + :ivar version: Version of the update. + :vartype version: str + :ivar publisher: Publisher of the update package. + :vartype publisher: str + :ivar release_link: Link to release notes for the update. + :vartype release_link: str + :ivar availability_type: Indicates the way the update content can be downloaded. Known values + are: "Local", "Online", and "Notify". + :vartype availability_type: str or ~azure.mgmt.azurestackhci.models.AvailabilityType + :ivar package_type: Customer-visible type of the update. + :vartype package_type: str + :ivar additional_properties: Extensible KV pairs serialized as a string. This is currently used + to report the stamp OEM family and hardware model information when an update is flagged as + Invalid for the stamp based on OEM type. + :vartype additional_properties: str + :ivar progress_percentage: Progress percentage of ongoing operation. Currently this property is + only valid when the update is in the Downloading state, where it maps to how much of the update + content has been downloaded. + :vartype progress_percentage: float + :ivar notify_message: Brief message with instructions for updates of AvailabilityType Notify. + :vartype notify_message: str """ _validation = { - "etag": {"readonly": True}, + "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - "etag": {"key": "etag", "type": "str"}, + "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, - "routes": {"key": "properties.routes", "type": "[Route]"}, - } - - def __init__(self, *, routes: Optional[List["_models.Route"]] = None, **kwargs: Any) -> None: + "system_data": {"key": "systemData", "type": "SystemData"}, + "location": {"key": "location", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "installed_date": {"key": "properties.installedDate", "type": "iso-8601"}, + "description": {"key": "properties.description", "type": "str"}, + "state": {"key": "properties.state", "type": "str"}, + "prerequisites": {"key": "properties.prerequisites", "type": "[UpdatePrerequisite]"}, + "component_versions": {"key": "properties.componentVersions", "type": "[PackageVersionInfo]"}, + "reboot_required": {"key": "properties.rebootRequired", "type": "str"}, + "health_state": {"key": "properties.healthState", "type": "str"}, + "health_check_result": {"key": "properties.healthCheckResult", "type": "[PrecheckResult]"}, + "health_check_date": {"key": "properties.healthCheckDate", "type": "iso-8601"}, + "package_path": {"key": "properties.packagePath", "type": "str"}, + "package_size_in_mb": {"key": "properties.packageSizeInMb", "type": "float"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "publisher": {"key": "properties.publisher", "type": "str"}, + "release_link": {"key": "properties.releaseLink", "type": "str"}, + "availability_type": {"key": "properties.availabilityType", "type": "str"}, + "package_type": {"key": "properties.packageType", "type": "str"}, + "additional_properties": {"key": "properties.additionalProperties", "type": "str"}, + "progress_percentage": {"key": "properties.updateStateProperties.progressPercentage", "type": "float"}, + "notify_message": {"key": "properties.updateStateProperties.notifyMessage", "type": "str"}, + } + + def __init__( # pylint: disable=too-many-locals + self, + *, + location: Optional[str] = None, + installed_date: Optional[datetime.datetime] = None, + description: Optional[str] = None, + state: Optional[Union[str, "_models.State"]] = None, + prerequisites: Optional[List["_models.UpdatePrerequisite"]] = None, + component_versions: Optional[List["_models.PackageVersionInfo"]] = None, + reboot_required: Optional[Union[str, "_models.RebootRequirement"]] = None, + health_state: Optional[Union[str, "_models.HealthState"]] = None, + health_check_result: Optional[List["_models.PrecheckResult"]] = None, + health_check_date: Optional[datetime.datetime] = None, + package_path: Optional[str] = None, + package_size_in_mb: Optional[float] = None, + display_name: Optional[str] = None, + version: Optional[str] = None, + publisher: Optional[str] = None, + release_link: Optional[str] = None, + availability_type: Optional[Union[str, "_models.AvailabilityType"]] = None, + package_type: Optional[str] = None, + additional_properties: Optional[str] = None, + progress_percentage: Optional[float] = None, + notify_message: Optional[str] = None, + **kwargs: Any + ) -> None: """ - :keyword routes: Collection of routes contained within a route table. - :paramtype routes: list[~azure.mgmt.azurestackhci.models.Route] + :keyword location: The geo-location where the resource lives. + :paramtype location: str + :keyword installed_date: Date that the update was installed. + :paramtype installed_date: ~datetime.datetime + :keyword description: Description of the update. + :paramtype description: str + :keyword state: State of the update as it relates to this stamp. Known values are: + "HasPrerequisite", "Obsolete", "Ready", "NotApplicableBecauseAnotherUpdateIsInProgress", + "Preparing", "Installing", "Installed", "PreparationFailed", "InstallationFailed", "Invalid", + "Recalled", "Downloading", "DownloadFailed", "HealthChecking", "HealthCheckFailed", + "ReadyToInstall", "ScanInProgress", "ScanFailed", and "AdditionalContentRequired". + :paramtype state: str or ~azure.mgmt.azurestackhci.models.State + :keyword prerequisites: If update State is HasPrerequisite, this property contains an array of + objects describing prerequisite updates before installing this update. Otherwise, it is empty. + :paramtype prerequisites: list[~azure.mgmt.azurestackhci.models.UpdatePrerequisite] + :keyword component_versions: An array of component versions for a Solution Bundle update, and + an empty array otherwise. + :paramtype component_versions: list[~azure.mgmt.azurestackhci.models.PackageVersionInfo] + :keyword reboot_required: Known values are: "Unknown", "True", and "False". + :paramtype reboot_required: str or ~azure.mgmt.azurestackhci.models.RebootRequirement + :keyword health_state: Overall health state for update-specific health checks. Known values + are: "Unknown", "Success", "Failure", "Warning", "Error", and "InProgress". + :paramtype health_state: str or ~azure.mgmt.azurestackhci.models.HealthState + :keyword health_check_result: An array of PrecheckResult objects. + :paramtype health_check_result: list[~azure.mgmt.azurestackhci.models.PrecheckResult] + :keyword health_check_date: Last time the package-specific checks were run. + :paramtype health_check_date: ~datetime.datetime + :keyword package_path: Path where the update package is available. + :paramtype package_path: str + :keyword package_size_in_mb: Size of the package. This value is a combination of the size from + update metadata and size of the payload that results from the live scan operation for OS update + content. + :paramtype package_size_in_mb: float + :keyword display_name: Display name of the Update. + :paramtype display_name: str + :keyword version: Version of the update. + :paramtype version: str + :keyword publisher: Publisher of the update package. + :paramtype publisher: str + :keyword release_link: Link to release notes for the update. + :paramtype release_link: str + :keyword availability_type: Indicates the way the update content can be downloaded. Known + values are: "Local", "Online", and "Notify". + :paramtype availability_type: str or ~azure.mgmt.azurestackhci.models.AvailabilityType + :keyword package_type: Customer-visible type of the update. + :paramtype package_type: str + :keyword additional_properties: Extensible KV pairs serialized as a string. This is currently + used to report the stamp OEM family and hardware model information when an update is flagged as + Invalid for the stamp based on OEM type. + :paramtype additional_properties: str + :keyword progress_percentage: Progress percentage of ongoing operation. Currently this property + is only valid when the update is in the Downloading state, where it maps to how much of the + update content has been downloaded. + :paramtype progress_percentage: float + :keyword notify_message: Brief message with instructions for updates of AvailabilityType + Notify. + :paramtype notify_message: str """ super().__init__(**kwargs) - self.etag = None - self.name = None - self.type = None - self.routes = routes + self.location = location + self.provisioning_state = None + self.installed_date = installed_date + self.description = description + self.state = state + self.prerequisites = prerequisites + self.component_versions = component_versions + self.reboot_required = reboot_required + self.health_state = health_state + self.health_check_result = health_check_result + self.health_check_date = health_check_date + self.package_path = package_path + self.package_size_in_mb = package_size_in_mb + self.display_name = display_name + self.version = version + self.publisher = publisher + self.release_link = release_link + self.availability_type = availability_type + self.package_type = package_type + self.additional_properties = additional_properties + self.progress_percentage = progress_percentage + self.notify_message = notify_message -class SshConfiguration(_serialization.Model): - """SSH configuration for Linux based VMs running on Azure. +class UpdateList(_serialization.Model): + """List of Updates. - :ivar public_keys: The list of SSH public keys used to authenticate with linux based VMs. - :vartype public_keys: list[~azure.mgmt.azurestackhci.models.SshPublicKey] + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of Updates. + :vartype value: list[~azure.mgmt.azurestackhci.models.Update] + :ivar next_link: Link to the next set of results. + :vartype next_link: str """ + _validation = { + "next_link": {"readonly": True}, + } + _attribute_map = { - "public_keys": {"key": "publicKeys", "type": "[SshPublicKey]"}, + "value": {"key": "value", "type": "[Update]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, *, public_keys: Optional[List["_models.SshPublicKey"]] = None, **kwargs: Any) -> None: + def __init__(self, *, value: Optional[List["_models.Update"]] = None, **kwargs: Any) -> None: """ - :keyword public_keys: The list of SSH public keys used to authenticate with linux based VMs. - :paramtype public_keys: list[~azure.mgmt.azurestackhci.models.SshPublicKey] + :keyword value: List of Updates. + :paramtype value: list[~azure.mgmt.azurestackhci.models.Update] """ super().__init__(**kwargs) - self.public_keys = public_keys + self.value = value + self.next_link = None -class SshPublicKey(_serialization.Model): - """Contains information about SSH certificate public key and the path on the Linux VM where the - public key is placed. +class UpdatePrerequisite(_serialization.Model): + """If update State is HasPrerequisite, this property contains an array of objects describing + prerequisite updates before installing this update. Otherwise, it is empty. - :ivar path: Specifies the full path on the created VM where ssh public key is stored. If the - file already exists, the specified key is appended to the file. Example: - /home/user/.ssh/authorized_keys. - :vartype path: str - :ivar key_data: SSH public key certificate used to authenticate with the VM through ssh. The - key needs to be at least 2048-bit and in ssh-rsa format. :code:`
`:code:`
` For creating - ssh keys, see [Create SSH keys on Linux and Mac for Linux VMs in - Azure]https://docs.microsoft.com/azure/virtual-machines/linux/create-ssh-keys-detailed). - :vartype key_data: str + :ivar update_type: Updatable component type. + :vartype update_type: str + :ivar version: Version of the prerequisite. + :vartype version: str + :ivar package_name: Friendly name of the prerequisite. + :vartype package_name: str """ _attribute_map = { - "path": {"key": "path", "type": "str"}, - "key_data": {"key": "keyData", "type": "str"}, + "update_type": {"key": "updateType", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "package_name": {"key": "packageName", "type": "str"}, } - def __init__(self, *, path: Optional[str] = None, key_data: Optional[str] = None, **kwargs: Any) -> None: + def __init__( + self, + *, + update_type: Optional[str] = None, + version: Optional[str] = None, + package_name: Optional[str] = None, + **kwargs: Any + ) -> None: """ - :keyword path: Specifies the full path on the created VM where ssh public key is stored. If the - file already exists, the specified key is appended to the file. Example: - /home/user/.ssh/authorized_keys. - :paramtype path: str - :keyword key_data: SSH public key certificate used to authenticate with the VM through ssh. The - key needs to be at least 2048-bit and in ssh-rsa format. :code:`
`:code:`
` For creating - ssh keys, see [Create SSH keys on Linux and Mac for Linux VMs in - Azure]https://docs.microsoft.com/azure/virtual-machines/linux/create-ssh-keys-detailed). - :paramtype key_data: str + :keyword update_type: Updatable component type. + :paramtype update_type: str + :keyword version: Version of the prerequisite. + :paramtype version: str + :keyword package_name: Friendly name of the prerequisite. + :paramtype package_name: str """ super().__init__(**kwargs) - self.path = path - self.key_data = key_data + self.update_type = update_type + self.version = version + self.package_name = package_name -class StorageContainers(TrackedResource): - """The storage container resource definition. +class UpdateRun(ProxyResource): # pylint: disable=too-many-instance-attributes + """Details of an Update run. Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -2567,19 +6907,39 @@ class StorageContainers(TrackedResource): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.azurestackhci.models.SystemData - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar location: The geo-location where the resource lives. Required. + :ivar location: The geo-location where the resource lives. :vartype location: str - :ivar extended_location: The extendedLocation of the resource. - :vartype extended_location: ~azure.mgmt.azurestackhci.models.ExtendedLocation - :ivar path: Path of the storage container on the disk. - :vartype path: str - :ivar provisioning_state: Provisioning state of the storage container. Known values are: - "Succeeded", "Failed", "InProgress", "Accepted", "Deleting", and "Canceled". - :vartype provisioning_state: str or ~azure.mgmt.azurestackhci.models.ProvisioningStateEnum - :ivar status: The observed state of storage containers. - :vartype status: ~azure.mgmt.azurestackhci.models.StorageContainerStatus + :ivar provisioning_state: Provisioning state of the UpdateRuns proxy resource. Known values + are: "NotSpecified", "Error", "Succeeded", "Failed", "Canceled", "Connected", "Disconnected", + "Deleted", "Creating", "Updating", "Deleting", "Moving", "PartiallySucceeded", + "PartiallyConnected", "InProgress", "Accepted", "Provisioning", and "DisableInProgress". + :vartype provisioning_state: str or ~azure.mgmt.azurestackhci.models.ProvisioningState + :ivar time_started: Timestamp of the update run was started. + :vartype time_started: ~datetime.datetime + :ivar last_updated_time: Timestamp of the most recently completed step in the update run. + :vartype last_updated_time: ~datetime.datetime + :ivar duration: Duration of the update run. + :vartype duration: str + :ivar state: State of the update run. Known values are: "Unknown", "Succeeded", "InProgress", + and "Failed". + :vartype state: str or ~azure.mgmt.azurestackhci.models.UpdateRunPropertiesState + :ivar name_properties_progress_name: Name of the step. + :vartype name_properties_progress_name: str + :ivar description: More detailed description of the step. + :vartype description: str + :ivar error_message: Error message, specified if the step is in a failed state. + :vartype error_message: str + :ivar status: Status of the step, bubbled up from the ECE action plan for installation + attempts. Values are: 'Success', 'Error', 'InProgress', and 'Unknown status'. + :vartype status: str + :ivar start_time_utc: When the step started, or empty if it has not started executing. + :vartype start_time_utc: ~datetime.datetime + :ivar end_time_utc: When the step reached a terminal state. + :vartype end_time_utc: ~datetime.datetime + :ivar last_updated_time_utc: Completion time of this step or the last completed sub-step. + :vartype last_updated_time_utc: ~datetime.datetime + :ivar steps: Recursive model for child steps of this step. + :vartype steps: list[~azure.mgmt.azurestackhci.models.Step] """ _validation = { @@ -2587,9 +6947,7 @@ class StorageContainers(TrackedResource): "name": {"readonly": True}, "type": {"readonly": True}, "system_data": {"readonly": True}, - "location": {"required": True}, "provisioning_state": {"readonly": True}, - "status": {"readonly": True}, } _attribute_map = { @@ -2597,396 +6955,409 @@ class StorageContainers(TrackedResource): "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, "system_data": {"key": "systemData", "type": "SystemData"}, - "tags": {"key": "tags", "type": "{str}"}, "location": {"key": "location", "type": "str"}, - "extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"}, - "path": {"key": "properties.path", "type": "str"}, "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "status": {"key": "properties.status", "type": "StorageContainerStatus"}, + "time_started": {"key": "properties.timeStarted", "type": "iso-8601"}, + "last_updated_time": {"key": "properties.lastUpdatedTime", "type": "iso-8601"}, + "duration": {"key": "properties.duration", "type": "str"}, + "state": {"key": "properties.state", "type": "str"}, + "name_properties_progress_name": {"key": "properties.progress.name", "type": "str"}, + "description": {"key": "properties.progress.description", "type": "str"}, + "error_message": {"key": "properties.progress.errorMessage", "type": "str"}, + "status": {"key": "properties.progress.status", "type": "str"}, + "start_time_utc": {"key": "properties.progress.startTimeUtc", "type": "iso-8601"}, + "end_time_utc": {"key": "properties.progress.endTimeUtc", "type": "iso-8601"}, + "last_updated_time_utc": {"key": "properties.progress.lastUpdatedTimeUtc", "type": "iso-8601"}, + "steps": {"key": "properties.progress.steps", "type": "[Step]"}, } def __init__( self, *, - location: str, - tags: Optional[Dict[str, str]] = None, - extended_location: Optional["_models.ExtendedLocation"] = None, - path: Optional[str] = None, + location: Optional[str] = None, + time_started: Optional[datetime.datetime] = None, + last_updated_time: Optional[datetime.datetime] = None, + duration: Optional[str] = None, + state: Optional[Union[str, "_models.UpdateRunPropertiesState"]] = None, + name_properties_progress_name: Optional[str] = None, + description: Optional[str] = None, + error_message: Optional[str] = None, + status: Optional[str] = None, + start_time_utc: Optional[datetime.datetime] = None, + end_time_utc: Optional[datetime.datetime] = None, + last_updated_time_utc: Optional[datetime.datetime] = None, + steps: Optional[List["_models.Step"]] = None, **kwargs: Any ) -> None: """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword location: The geo-location where the resource lives. Required. + :keyword location: The geo-location where the resource lives. :paramtype location: str - :keyword extended_location: The extendedLocation of the resource. - :paramtype extended_location: ~azure.mgmt.azurestackhci.models.ExtendedLocation - :keyword path: Path of the storage container on the disk. - :paramtype path: str + :keyword time_started: Timestamp of the update run was started. + :paramtype time_started: ~datetime.datetime + :keyword last_updated_time: Timestamp of the most recently completed step in the update run. + :paramtype last_updated_time: ~datetime.datetime + :keyword duration: Duration of the update run. + :paramtype duration: str + :keyword state: State of the update run. Known values are: "Unknown", "Succeeded", + "InProgress", and "Failed". + :paramtype state: str or ~azure.mgmt.azurestackhci.models.UpdateRunPropertiesState + :keyword name_properties_progress_name: Name of the step. + :paramtype name_properties_progress_name: str + :keyword description: More detailed description of the step. + :paramtype description: str + :keyword error_message: Error message, specified if the step is in a failed state. + :paramtype error_message: str + :keyword status: Status of the step, bubbled up from the ECE action plan for installation + attempts. Values are: 'Success', 'Error', 'InProgress', and 'Unknown status'. + :paramtype status: str + :keyword start_time_utc: When the step started, or empty if it has not started executing. + :paramtype start_time_utc: ~datetime.datetime + :keyword end_time_utc: When the step reached a terminal state. + :paramtype end_time_utc: ~datetime.datetime + :keyword last_updated_time_utc: Completion time of this step or the last completed sub-step. + :paramtype last_updated_time_utc: ~datetime.datetime + :keyword steps: Recursive model for child steps of this step. + :paramtype steps: list[~azure.mgmt.azurestackhci.models.Step] """ - super().__init__(tags=tags, location=location, **kwargs) - self.extended_location = extended_location - self.path = path + super().__init__(**kwargs) + self.location = location self.provisioning_state = None - self.status = None + self.time_started = time_started + self.last_updated_time = last_updated_time + self.duration = duration + self.state = state + self.name_properties_progress_name = name_properties_progress_name + self.description = description + self.error_message = error_message + self.status = status + self.start_time_utc = start_time_utc + self.end_time_utc = end_time_utc + self.last_updated_time_utc = last_updated_time_utc + self.steps = steps -class StorageContainersListResult(_serialization.Model): - """StorageContainersListResult. +class UpdateRunList(_serialization.Model): + """List of Update runs. - :ivar value: - :vartype value: list[~azure.mgmt.azurestackhci.models.StorageContainers] - :ivar next_link: + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of Update runs. + :vartype value: list[~azure.mgmt.azurestackhci.models.UpdateRun] + :ivar next_link: Link to the next set of results. :vartype next_link: str """ + _validation = { + "next_link": {"readonly": True}, + } + _attribute_map = { - "value": {"key": "value", "type": "[StorageContainers]"}, + "value": {"key": "value", "type": "[UpdateRun]"}, "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.StorageContainers"]] = None, - next_link: Optional[str] = None, - **kwargs: Any - ) -> None: + def __init__(self, *, value: Optional[List["_models.UpdateRun"]] = None, **kwargs: Any) -> None: """ - :keyword value: - :paramtype value: list[~azure.mgmt.azurestackhci.models.StorageContainers] - :keyword next_link: - :paramtype next_link: str + :keyword value: List of Update runs. + :paramtype value: list[~azure.mgmt.azurestackhci.models.UpdateRun] """ super().__init__(**kwargs) self.value = value - self.next_link = next_link - - -class StorageContainerStatus(_serialization.Model): - """The observed state of storage containers. - - :ivar error_code: StorageContainer provisioning error code. - :vartype error_code: str - :ivar error_message: Descriptive error message. - :vartype error_message: str - :ivar available_size_mb: Amount of space available on the disk in MB. - :vartype available_size_mb: int - :ivar container_size_mb: Total size of the disk in MB. - :vartype container_size_mb: int - :ivar provisioning_status: - :vartype provisioning_status: - ~azure.mgmt.azurestackhci.models.StorageContainerStatusProvisioningStatus - """ - - _attribute_map = { - "error_code": {"key": "errorCode", "type": "str"}, - "error_message": {"key": "errorMessage", "type": "str"}, - "available_size_mb": {"key": "availableSizeMB", "type": "int"}, - "container_size_mb": {"key": "containerSizeMB", "type": "int"}, - "provisioning_status": {"key": "provisioningStatus", "type": "StorageContainerStatusProvisioningStatus"}, - } + self.next_link = None - def __init__( - self, - *, - error_code: Optional[str] = None, - error_message: Optional[str] = None, - available_size_mb: Optional[int] = None, - container_size_mb: Optional[int] = None, - provisioning_status: Optional["_models.StorageContainerStatusProvisioningStatus"] = None, - **kwargs: Any - ) -> None: - """ - :keyword error_code: StorageContainer provisioning error code. - :paramtype error_code: str - :keyword error_message: Descriptive error message. - :paramtype error_message: str - :keyword available_size_mb: Amount of space available on the disk in MB. - :paramtype available_size_mb: int - :keyword container_size_mb: Total size of the disk in MB. - :paramtype container_size_mb: int - :keyword provisioning_status: - :paramtype provisioning_status: - ~azure.mgmt.azurestackhci.models.StorageContainerStatusProvisioningStatus - """ - super().__init__(**kwargs) - self.error_code = error_code - self.error_message = error_message - self.available_size_mb = available_size_mb - self.container_size_mb = container_size_mb - self.provisioning_status = provisioning_status +class UpdateSummaries(ProxyResource): # pylint: disable=too-many-instance-attributes + """Get the update summaries for the cluster. -class StorageContainerStatusProvisioningStatus(_serialization.Model): - """StorageContainerStatusProvisioningStatus. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar operation_id: The ID of the operation performed on the storage container. - :vartype operation_id: str - :ivar status: The status of the operation performed on the storage container [Succeeded, - Failed, InProgress]. Known values are: "Succeeded", "Failed", and "InProgress". - :vartype status: str or ~azure.mgmt.azurestackhci.models.Status + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.azurestackhci.models.SystemData + :ivar location: The geo-location where the resource lives. + :vartype location: str + :ivar provisioning_state: Provisioning state of the UpdateSummaries proxy resource. Known + values are: "NotSpecified", "Error", "Succeeded", "Failed", "Canceled", "Connected", + "Disconnected", "Deleted", "Creating", "Updating", "Deleting", "Moving", "PartiallySucceeded", + "PartiallyConnected", "InProgress", "Accepted", "Provisioning", and "DisableInProgress". + :vartype provisioning_state: str or ~azure.mgmt.azurestackhci.models.ProvisioningState + :ivar oem_family: OEM family name. + :vartype oem_family: str + :ivar hardware_model: Name of the hardware model. + :vartype hardware_model: str + :ivar package_versions: Current version of each updatable component. + :vartype package_versions: list[~azure.mgmt.azurestackhci.models.PackageVersionInfo] + :ivar current_version: Current Solution Bundle version of the stamp. + :vartype current_version: str + :ivar last_updated: Last time an update installation completed successfully. + :vartype last_updated: ~datetime.datetime + :ivar last_checked: Last time the update service successfully checked for updates. + :vartype last_checked: ~datetime.datetime + :ivar health_state: Overall health state for update-specific health checks. Known values are: + "Unknown", "Success", "Failure", "Warning", "Error", and "InProgress". + :vartype health_state: str or ~azure.mgmt.azurestackhci.models.HealthState + :ivar health_check_result: An array of pre-check result objects. + :vartype health_check_result: list[~azure.mgmt.azurestackhci.models.PrecheckResult] + :ivar health_check_date: Last time the package-specific checks were run. + :vartype health_check_date: ~datetime.datetime + :ivar state: Overall update state of the stamp. Known values are: "Unknown", + "AppliedSuccessfully", "UpdateAvailable", "UpdateInProgress", "UpdateFailed", "NeedsAttention", + "PreparationInProgress", and "PreparationFailed". + :vartype state: str or ~azure.mgmt.azurestackhci.models.UpdateSummariesPropertiesState """ + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + } + _attribute_map = { - "operation_id": {"key": "operationId", "type": "str"}, - "status": {"key": "status", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "location": {"key": "location", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "oem_family": {"key": "properties.oemFamily", "type": "str"}, + "hardware_model": {"key": "properties.hardwareModel", "type": "str"}, + "package_versions": {"key": "properties.packageVersions", "type": "[PackageVersionInfo]"}, + "current_version": {"key": "properties.currentVersion", "type": "str"}, + "last_updated": {"key": "properties.lastUpdated", "type": "iso-8601"}, + "last_checked": {"key": "properties.lastChecked", "type": "iso-8601"}, + "health_state": {"key": "properties.healthState", "type": "str"}, + "health_check_result": {"key": "properties.healthCheckResult", "type": "[PrecheckResult]"}, + "health_check_date": {"key": "properties.healthCheckDate", "type": "iso-8601"}, + "state": {"key": "properties.state", "type": "str"}, } def __init__( self, *, - operation_id: Optional[str] = None, - status: Optional[Union[str, "_models.Status"]] = None, + location: Optional[str] = None, + oem_family: Optional[str] = None, + hardware_model: Optional[str] = None, + package_versions: Optional[List["_models.PackageVersionInfo"]] = None, + current_version: Optional[str] = None, + last_updated: Optional[datetime.datetime] = None, + last_checked: Optional[datetime.datetime] = None, + health_state: Optional[Union[str, "_models.HealthState"]] = None, + health_check_result: Optional[List["_models.PrecheckResult"]] = None, + health_check_date: Optional[datetime.datetime] = None, + state: Optional[Union[str, "_models.UpdateSummariesPropertiesState"]] = None, **kwargs: Any ) -> None: """ - :keyword operation_id: The ID of the operation performed on the storage container. - :paramtype operation_id: str - :keyword status: The status of the operation performed on the storage container [Succeeded, - Failed, InProgress]. Known values are: "Succeeded", "Failed", and "InProgress". - :paramtype status: str or ~azure.mgmt.azurestackhci.models.Status + :keyword location: The geo-location where the resource lives. + :paramtype location: str + :keyword oem_family: OEM family name. + :paramtype oem_family: str + :keyword hardware_model: Name of the hardware model. + :paramtype hardware_model: str + :keyword package_versions: Current version of each updatable component. + :paramtype package_versions: list[~azure.mgmt.azurestackhci.models.PackageVersionInfo] + :keyword current_version: Current Solution Bundle version of the stamp. + :paramtype current_version: str + :keyword last_updated: Last time an update installation completed successfully. + :paramtype last_updated: ~datetime.datetime + :keyword last_checked: Last time the update service successfully checked for updates. + :paramtype last_checked: ~datetime.datetime + :keyword health_state: Overall health state for update-specific health checks. Known values + are: "Unknown", "Success", "Failure", "Warning", "Error", and "InProgress". + :paramtype health_state: str or ~azure.mgmt.azurestackhci.models.HealthState + :keyword health_check_result: An array of pre-check result objects. + :paramtype health_check_result: list[~azure.mgmt.azurestackhci.models.PrecheckResult] + :keyword health_check_date: Last time the package-specific checks were run. + :paramtype health_check_date: ~datetime.datetime + :keyword state: Overall update state of the stamp. Known values are: "Unknown", + "AppliedSuccessfully", "UpdateAvailable", "UpdateInProgress", "UpdateFailed", "NeedsAttention", + "PreparationInProgress", and "PreparationFailed". + :paramtype state: str or ~azure.mgmt.azurestackhci.models.UpdateSummariesPropertiesState """ super().__init__(**kwargs) - self.operation_id = operation_id - self.status = status + self.location = location + self.provisioning_state = None + self.oem_family = oem_family + self.hardware_model = hardware_model + self.package_versions = package_versions + self.current_version = current_version + self.last_updated = last_updated + self.last_checked = last_checked + self.health_state = health_state + self.health_check_result = health_check_result + self.health_check_date = health_check_date + self.state = state -class StorageContainersUpdateRequest(_serialization.Model): - """The storage container resource patch definition. +class UpdateSummariesList(_serialization.Model): + """List of Update Summaries. - :ivar tags: Resource tags. - :vartype tags: dict[str, str] + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of Update Summaries. + :vartype value: list[~azure.mgmt.azurestackhci.models.UpdateSummaries] + :ivar next_link: Link to the next set of results. + :vartype next_link: str """ + _validation = { + "next_link": {"readonly": True}, + } + _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, + "value": {"key": "value", "type": "[UpdateSummaries]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + def __init__(self, *, value: Optional[List["_models.UpdateSummaries"]] = None, **kwargs: Any) -> None: """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] + :keyword value: List of Update Summaries. + :paramtype value: list[~azure.mgmt.azurestackhci.models.UpdateSummaries] """ super().__init__(**kwargs) - self.tags = tags + self.value = value + self.next_link = None -class StorageProfileUpdate(_serialization.Model): - """StorageProfileUpdate. +class UploadCertificateRequest(_serialization.Model): + """UploadCertificateRequest. - :ivar data_disks: adds data disks to the virtual machine instance for the update call. - :vartype data_disks: list[~azure.mgmt.azurestackhci.models.StorageProfileUpdateDataDisksItem] + :ivar properties: + :vartype properties: ~azure.mgmt.azurestackhci.models.RawCertificateData """ _attribute_map = { - "data_disks": {"key": "dataDisks", "type": "[StorageProfileUpdateDataDisksItem]"}, + "properties": {"key": "properties", "type": "RawCertificateData"}, } - def __init__( - self, *, data_disks: Optional[List["_models.StorageProfileUpdateDataDisksItem"]] = None, **kwargs: Any - ) -> None: + def __init__(self, *, properties: Optional["_models.RawCertificateData"] = None, **kwargs: Any) -> None: """ - :keyword data_disks: adds data disks to the virtual machine instance for the update call. - :paramtype data_disks: list[~azure.mgmt.azurestackhci.models.StorageProfileUpdateDataDisksItem] + :keyword properties: + :paramtype properties: ~azure.mgmt.azurestackhci.models.RawCertificateData """ super().__init__(**kwargs) - self.data_disks = data_disks + self.properties = properties -class StorageProfileUpdateDataDisksItem(_serialization.Model): - """StorageProfileUpdateDataDisksItem. +class UserAssignedIdentity(_serialization.Model): + """User assigned identity properties. - :ivar id: - :vartype id: str + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal ID of the assigned identity. + :vartype principal_id: str + :ivar client_id: The client ID of the assigned identity. + :vartype client_id: str """ + _validation = { + "principal_id": {"readonly": True}, + "client_id": {"readonly": True}, + } + _attribute_map = { - "id": {"key": "id", "type": "str"}, + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, } - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: - :paramtype id: str - """ + def __init__(self, **kwargs: Any) -> None: + """ """ super().__init__(**kwargs) - self.id = id + self.principal_id = None + self.client_id = None -class Subnet(_serialization.Model): - """Subnet. +class ValidateRequest(_serialization.Model): + """The validate request for Edge Device. - :ivar name: Name - The name of the resource that is unique within a resource group. This name - can be used to access the resource. - :vartype name: str - :ivar address_prefix: The address prefix for the subnet: Cidr for this subnet - IPv4, IPv6. - :vartype address_prefix: str - :ivar address_prefixes: List of address prefixes for the subnet. - :vartype address_prefixes: list[str] - :ivar ip_allocation_method: IPAllocationMethod - The IP address allocation method. Possible - values include: 'Static', 'Dynamic'. Known values are: "Dynamic" and "Static". - :vartype ip_allocation_method: str or ~azure.mgmt.azurestackhci.models.IpAllocationMethodEnum - :ivar ip_configuration_references: IPConfigurationReferences - list of - IPConfigurationReferences. - :vartype ip_configuration_references: - list[~azure.mgmt.azurestackhci.models.SubnetPropertiesFormatIpConfigurationReferencesItem] - :ivar route_table: Route table resource. - :vartype route_table: ~azure.mgmt.azurestackhci.models.RouteTable - :ivar ip_pools: network associated pool of IP Addresses. - :vartype ip_pools: list[~azure.mgmt.azurestackhci.models.IPPool] - :ivar vlan: Vlan to use for the subnet. - :vartype vlan: int + All required parameters must be populated in order to send to server. + + :ivar edge_device_ids: Node Ids against which, current node has to be validated. Required. + :vartype edge_device_ids: list[str] + :ivar additional_info: additional Info required for validation. + :vartype additional_info: str """ _validation = { - "name": {"pattern": r"^[a-zA-Z0-9]$|^[a-zA-Z0-9][-._a-zA-Z0-9]{0,78}[_a-zA-Z0-9]$"}, + "edge_device_ids": {"required": True}, } _attribute_map = { - "name": {"key": "name", "type": "str"}, - "address_prefix": {"key": "properties.addressPrefix", "type": "str"}, - "address_prefixes": {"key": "properties.addressPrefixes", "type": "[str]"}, - "ip_allocation_method": {"key": "properties.ipAllocationMethod", "type": "str"}, - "ip_configuration_references": { - "key": "properties.ipConfigurationReferences", - "type": "[SubnetPropertiesFormatIpConfigurationReferencesItem]", - }, - "route_table": {"key": "properties.routeTable", "type": "RouteTable"}, - "ip_pools": {"key": "properties.ipPools", "type": "[IPPool]"}, - "vlan": {"key": "properties.vlan", "type": "int"}, + "edge_device_ids": {"key": "edgeDeviceIds", "type": "[str]"}, + "additional_info": {"key": "additionalInfo", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - address_prefix: Optional[str] = None, - address_prefixes: Optional[List[str]] = None, - ip_allocation_method: Optional[Union[str, "_models.IpAllocationMethodEnum"]] = None, - ip_configuration_references: Optional[ - List["_models.SubnetPropertiesFormatIpConfigurationReferencesItem"] - ] = None, - route_table: Optional["_models.RouteTable"] = None, - ip_pools: Optional[List["_models.IPPool"]] = None, - vlan: Optional[int] = None, - **kwargs: Any - ) -> None: + def __init__(self, *, edge_device_ids: List[str], additional_info: Optional[str] = None, **kwargs: Any) -> None: """ - :keyword name: Name - The name of the resource that is unique within a resource group. This - name can be used to access the resource. - :paramtype name: str - :keyword address_prefix: The address prefix for the subnet: Cidr for this subnet - IPv4, IPv6. - :paramtype address_prefix: str - :keyword address_prefixes: List of address prefixes for the subnet. - :paramtype address_prefixes: list[str] - :keyword ip_allocation_method: IPAllocationMethod - The IP address allocation method. Possible - values include: 'Static', 'Dynamic'. Known values are: "Dynamic" and "Static". - :paramtype ip_allocation_method: str or ~azure.mgmt.azurestackhci.models.IpAllocationMethodEnum - :keyword ip_configuration_references: IPConfigurationReferences - list of - IPConfigurationReferences. - :paramtype ip_configuration_references: - list[~azure.mgmt.azurestackhci.models.SubnetPropertiesFormatIpConfigurationReferencesItem] - :keyword route_table: Route table resource. - :paramtype route_table: ~azure.mgmt.azurestackhci.models.RouteTable - :keyword ip_pools: network associated pool of IP Addresses. - :paramtype ip_pools: list[~azure.mgmt.azurestackhci.models.IPPool] - :keyword vlan: Vlan to use for the subnet. - :paramtype vlan: int + :keyword edge_device_ids: Node Ids against which, current node has to be validated. Required. + :paramtype edge_device_ids: list[str] + :keyword additional_info: additional Info required for validation. + :paramtype additional_info: str """ super().__init__(**kwargs) - self.name = name - self.address_prefix = address_prefix - self.address_prefixes = address_prefixes - self.ip_allocation_method = ip_allocation_method - self.ip_configuration_references = ip_configuration_references - self.route_table = route_table - self.ip_pools = ip_pools - self.vlan = vlan + self.edge_device_ids = edge_device_ids + self.additional_info = additional_info -class SubnetPropertiesFormatIpConfigurationReferencesItem(_serialization.Model): - """IPConfigurationReference - Describes a IPConfiguration under the virtual network. +class ValidateResponse(_serialization.Model): + """An Accepted response with an Operation-Location header. - :ivar id: IPConfigurationID. - :vartype id: str + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar status: edge device validation status. + :vartype status: str """ + _validation = { + "status": {"readonly": True}, + } + _attribute_map = { - "id": {"key": "ID", "type": "str"}, + "status": {"key": "status", "type": "str"}, } - def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: IPConfigurationID. - :paramtype id: str - """ + def __init__(self, **kwargs: Any) -> None: + """ """ super().__init__(**kwargs) - self.id = id + self.status = None -class SystemData(_serialization.Model): - """Metadata pertaining to creation and last modification of the resource. +class ValidationStatus(_serialization.Model): + """The ValidationStatus of AzureStackHCI Cluster. - :ivar created_by: The identity that created the resource. - :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :vartype created_by_type: str or ~azure.mgmt.azurestackhci.models.CreatedByType - :ivar created_at: The timestamp of resource creation (UTC). - :vartype created_at: ~datetime.datetime - :ivar last_modified_by: The identity that last modified the resource. - :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Known values - are: "User", "Application", "ManagedIdentity", and "Key". - :vartype last_modified_by_type: str or ~azure.mgmt.azurestackhci.models.CreatedByType - :ivar last_modified_at: The timestamp of resource last modification (UTC). - :vartype last_modified_at: ~datetime.datetime + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar status: Status of AzureStackHCI Cluster Deployment. + :vartype status: str + :ivar steps: List of steps of AzureStackHCI Cluster Deployment. + :vartype steps: list[~azure.mgmt.azurestackhci.models.DeploymentStep] """ + _validation = { + "status": {"readonly": True}, + "steps": {"readonly": True}, + } + _attribute_map = { - "created_by": {"key": "createdBy", "type": "str"}, - "created_by_type": {"key": "createdByType", "type": "str"}, - "created_at": {"key": "createdAt", "type": "iso-8601"}, - "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, - "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, - "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, + "status": {"key": "status", "type": "str"}, + "steps": {"key": "steps", "type": "[DeploymentStep]"}, } - def __init__( - self, - *, - created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - created_at: Optional[datetime.datetime] = None, - last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, - last_modified_at: Optional[datetime.datetime] = None, - **kwargs: Any - ) -> None: - """ - :keyword created_by: The identity that created the resource. - :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Known values are: - "User", "Application", "ManagedIdentity", and "Key". - :paramtype created_by_type: str or ~azure.mgmt.azurestackhci.models.CreatedByType - :keyword created_at: The timestamp of resource creation (UTC). - :paramtype created_at: ~datetime.datetime - :keyword last_modified_by: The identity that last modified the resource. - :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Known - values are: "User", "Application", "ManagedIdentity", and "Key". - :paramtype last_modified_by_type: str or ~azure.mgmt.azurestackhci.models.CreatedByType - :keyword last_modified_at: The timestamp of resource last modification (UTC). - :paramtype last_modified_at: ~datetime.datetime - """ + def __init__(self, **kwargs: Any) -> None: + """ """ super().__init__(**kwargs) - self.created_by = created_by - self.created_by_type = created_by_type - self.created_at = created_at - self.last_modified_by = last_modified_by - self.last_modified_by_type = last_modified_by_type - self.last_modified_at = last_modified_at + self.status = None + self.steps = None class VirtualHardDisks(TrackedResource): # pylint: disable=too-many-instance-attributes @@ -2994,10 +7365,10 @@ class VirtualHardDisks(TrackedResource): # pylint: disable=too-many-instance-at 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. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -3203,7 +7574,10 @@ class VirtualHardDiskStatusProvisioningStatus(_serialization.Model): :ivar operation_id: The ID of the operation performed on the virtual hard disk. :vartype operation_id: str :ivar status: The status of the operation performed on the virtual hard disk [Succeeded, - Failed, InProgress]. Known values are: "Succeeded", "Failed", and "InProgress". + Failed, InProgress]. Known values are: "NotYetRegistered", "ConnectedRecently", + "NotConnectedRecently", "Disconnected", "Error", "NotSpecified", "ValidationInProgress", + "ValidationSuccess", "ValidationFailed", "DeploymentInProgress", "DeploymentFailed", + "DeploymentSuccess", "Succeeded", "Failed", and "InProgress". :vartype status: str or ~azure.mgmt.azurestackhci.models.Status """ @@ -3223,7 +7597,10 @@ def __init__( :keyword operation_id: The ID of the operation performed on the virtual hard disk. :paramtype operation_id: str :keyword status: The status of the operation performed on the virtual hard disk [Succeeded, - Failed, InProgress]. Known values are: "Succeeded", "Failed", and "InProgress". + Failed, InProgress]. Known values are: "NotYetRegistered", "ConnectedRecently", + "NotConnectedRecently", "Disconnected", "Error", "NotSpecified", "ValidationInProgress", + "ValidationSuccess", "ValidationFailed", "DeploymentInProgress", "DeploymentFailed", + "DeploymentSuccess", "Succeeded", "Failed", and "InProgress". :paramtype status: str or ~azure.mgmt.azurestackhci.models.Status """ super().__init__(**kwargs) @@ -3289,7 +7666,7 @@ class VirtualMachineInstance(ProxyResource): # pylint: disable=too-many-instanc Variables are only populated by the server, and will be ignored when sending a request. :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -3479,7 +7856,7 @@ def __init__( self.next_link = next_link -class VirtualMachineInstancePropertiesHardwareProfile(_serialization.Model): +class VirtualMachineInstancePropertiesHardwareProfile(_serialization.Model): # pylint: disable=name-too-long """HardwareProfile - Specifies the hardware settings for the virtual machine instance. :ivar vm_size: Known values are: "Default", "Standard_A2_v2", "Standard_A4_v2", @@ -3542,7 +7919,9 @@ def __init__( self.dynamic_memory_config = dynamic_memory_config -class VirtualMachineInstancePropertiesHardwareProfileDynamicMemoryConfig(_serialization.Model): +class VirtualMachineInstancePropertiesHardwareProfileDynamicMemoryConfig( + _serialization.Model +): # pylint: disable=name-too-long """VirtualMachineInstancePropertiesHardwareProfileDynamicMemoryConfig. :ivar maximum_memory_mb: @@ -3587,7 +7966,7 @@ def __init__( self.target_memory_buffer = target_memory_buffer -class VirtualMachineInstancePropertiesNetworkProfile(_serialization.Model): +class VirtualMachineInstancePropertiesNetworkProfile(_serialization.Model): # pylint: disable=name-too-long """NetworkProfile - describes the network configuration the virtual machine instance. :ivar network_interfaces: NetworkInterfaces - list of network interfaces to be attached to the @@ -3621,7 +8000,9 @@ def __init__( self.network_interfaces = network_interfaces -class VirtualMachineInstancePropertiesNetworkProfileNetworkInterfacesItem(_serialization.Model): +class VirtualMachineInstancePropertiesNetworkProfileNetworkInterfacesItem( + _serialization.Model +): # pylint: disable=name-too-long """VirtualMachineInstancePropertiesNetworkProfileNetworkInterfacesItem. :ivar id: ID - Resource Id of the network interface. @@ -3641,7 +8022,7 @@ def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylin self.id = id -class VirtualMachineInstancePropertiesOsProfile(_serialization.Model): +class VirtualMachineInstancePropertiesOsProfile(_serialization.Model): # pylint: disable=name-too-long """OsProfile - describes the configuration of the operating system and sets login data. :ivar admin_password: AdminPassword - admin password. @@ -3706,7 +8087,9 @@ def __init__( self.windows_configuration = windows_configuration -class VirtualMachineInstancePropertiesOsProfileLinuxConfiguration(_serialization.Model): +class VirtualMachineInstancePropertiesOsProfileLinuxConfiguration( + _serialization.Model +): # pylint: disable=name-too-long """LinuxConfiguration - linux specific configuration values for the virtual machine instance. :ivar disable_password_authentication: DisablePasswordAuthentication - whether password @@ -3758,7 +8141,9 @@ def __init__( self.provision_vm_config_agent = provision_vm_config_agent -class VirtualMachineInstancePropertiesOsProfileWindowsConfiguration(_serialization.Model): +class VirtualMachineInstancePropertiesOsProfileWindowsConfiguration( + _serialization.Model +): # pylint: disable=name-too-long """Windows Configuration for the virtual machine instance. :ivar enable_automatic_updates: Whether to EnableAutomaticUpdates on the machine. @@ -3815,7 +8200,7 @@ def __init__( self.provision_vm_config_agent = provision_vm_config_agent -class VirtualMachineInstancePropertiesSecurityProfile(_serialization.Model): +class VirtualMachineInstancePropertiesSecurityProfile(_serialization.Model): # pylint: disable=name-too-long """SecurityProfile - Specifies the security settings for the virtual machine instance. :ivar enable_tpm: @@ -3860,7 +8245,9 @@ def __init__( self.security_type = security_type -class VirtualMachineInstancePropertiesSecurityProfileUefiSettings(_serialization.Model): +class VirtualMachineInstancePropertiesSecurityProfileUefiSettings( + _serialization.Model +): # pylint: disable=name-too-long """VirtualMachineInstancePropertiesSecurityProfileUefiSettings. :ivar secure_boot_enabled: Specifies whether secure boot should be enabled on the virtual @@ -3882,7 +8269,7 @@ def __init__(self, *, secure_boot_enabled: bool = False, **kwargs: Any) -> None: self.secure_boot_enabled = secure_boot_enabled -class VirtualMachineInstancePropertiesStorageProfile(_serialization.Model): +class VirtualMachineInstancePropertiesStorageProfile(_serialization.Model): # pylint: disable=name-too-long """StorageProfile - contains information about the disks and storage information for the virtual machine instance. @@ -3940,7 +8327,9 @@ def __init__( self.vm_config_storage_path_id = vm_config_storage_path_id -class VirtualMachineInstancePropertiesStorageProfileDataDisksItem(_serialization.Model): +class VirtualMachineInstancePropertiesStorageProfileDataDisksItem( + _serialization.Model +): # pylint: disable=name-too-long """VirtualMachineInstancePropertiesStorageProfileDataDisksItem. :ivar id: Resource ID of the data disk. @@ -3960,7 +8349,9 @@ def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylin self.id = id -class VirtualMachineInstancePropertiesStorageProfileImageReference(_serialization.Model): +class VirtualMachineInstancePropertiesStorageProfileImageReference( + _serialization.Model +): # pylint: disable=name-too-long """Which Image to use for the virtual machine instance. :ivar id: Resource ID of the image. @@ -3980,7 +8371,7 @@ def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylin self.id = id -class VirtualMachineInstancePropertiesStorageProfileOsDisk(_serialization.Model): +class VirtualMachineInstancePropertiesStorageProfileOsDisk(_serialization.Model): # pylint: disable=name-too-long """VHD to attach as OS disk. :ivar id: Resource ID of the OS disk. @@ -4066,13 +8457,16 @@ def __init__( self.provisioning_status = provisioning_status -class VirtualMachineInstanceStatusProvisioningStatus(_serialization.Model): +class VirtualMachineInstanceStatusProvisioningStatus(_serialization.Model): # pylint: disable=name-too-long """VirtualMachineInstanceStatusProvisioningStatus. :ivar operation_id: The ID of the operation performed on the virtual machine instance. :vartype operation_id: str :ivar status: The status of the operation performed on the virtual machine instance [Succeeded, - Failed, InProgress]. Known values are: "Succeeded", "Failed", and "InProgress". + Failed, InProgress]. Known values are: "NotYetRegistered", "ConnectedRecently", + "NotConnectedRecently", "Disconnected", "Error", "NotSpecified", "ValidationInProgress", + "ValidationSuccess", "ValidationFailed", "DeploymentInProgress", "DeploymentFailed", + "DeploymentSuccess", "Succeeded", "Failed", and "InProgress". :vartype status: str or ~azure.mgmt.azurestackhci.models.Status """ @@ -4092,7 +8486,10 @@ def __init__( :keyword operation_id: The ID of the operation performed on the virtual machine instance. :paramtype operation_id: str :keyword status: The status of the operation performed on the virtual machine instance - [Succeeded, Failed, InProgress]. Known values are: "Succeeded", "Failed", and "InProgress". + [Succeeded, Failed, InProgress]. Known values are: "NotYetRegistered", "ConnectedRecently", + "NotConnectedRecently", "Disconnected", "Error", "NotSpecified", "ValidationInProgress", + "ValidationSuccess", "ValidationFailed", "DeploymentInProgress", "DeploymentFailed", + "DeploymentSuccess", "Succeeded", "Failed", and "InProgress". :paramtype status: str or ~azure.mgmt.azurestackhci.models.Status """ super().__init__(**kwargs) @@ -4202,3 +8599,31 @@ def __init__( """ super().__init__(**kwargs) self.vm_agent = vm_agent + + +class VirtualSwitchConfigurationOverrides(_serialization.Model): + """The VirtualSwitchConfigurationOverrides of a cluster. + + :ivar enable_iov: Enable IoV for Virtual Switch. + :vartype enable_iov: str + :ivar load_balancing_algorithm: Load Balancing Algorithm for Virtual Switch. + :vartype load_balancing_algorithm: str + """ + + _attribute_map = { + "enable_iov": {"key": "enableIov", "type": "str"}, + "load_balancing_algorithm": {"key": "loadBalancingAlgorithm", "type": "str"}, + } + + def __init__( + self, *, enable_iov: Optional[str] = None, load_balancing_algorithm: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword enable_iov: Enable IoV for Virtual Switch. + :paramtype enable_iov: str + :keyword load_balancing_algorithm: Load Balancing Algorithm for Virtual Switch. + :paramtype load_balancing_algorithm: str + """ + super().__init__(**kwargs) + self.enable_iov = enable_iov + self.load_balancing_algorithm = load_balancing_algorithm diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/__init__.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/__init__.py index 1ff6bf5d9fef..2eed2d52b4ab 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/__init__.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/__init__.py @@ -6,12 +6,24 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from ._arc_settings_operations import ArcSettingsOperations +from ._clusters_operations import ClustersOperations +from ._deployment_settings_operations import DeploymentSettingsOperations +from ._edge_devices_operations import EdgeDevicesOperations +from ._extensions_operations import ExtensionsOperations from ._gallery_images_operations import GalleryImagesOperations -from ._operations import Operations from ._logical_networks_operations import LogicalNetworksOperations from ._marketplace_gallery_images_operations import MarketplaceGalleryImagesOperations from ._network_interfaces_operations import NetworkInterfacesOperations +from ._offers_operations import OffersOperations +from ._operations import Operations +from ._publishers_operations import PublishersOperations +from ._security_settings_operations import SecuritySettingsOperations +from ._skus_operations import SkusOperations from ._storage_containers_operations import StorageContainersOperations +from ._update_runs_operations import UpdateRunsOperations +from ._update_summaries_operations import UpdateSummariesOperations +from ._updates_operations import UpdatesOperations from ._virtual_hard_disks_operations import VirtualHardDisksOperations from ._virtual_machine_instances_operations import VirtualMachineInstancesOperations from ._hybrid_identity_metadata_operations import HybridIdentityMetadataOperations @@ -23,12 +35,24 @@ from ._patch import patch_sdk as _patch_sdk __all__ = [ + "ArcSettingsOperations", + "ClustersOperations", + "DeploymentSettingsOperations", + "EdgeDevicesOperations", + "ExtensionsOperations", "GalleryImagesOperations", - "Operations", "LogicalNetworksOperations", "MarketplaceGalleryImagesOperations", "NetworkInterfacesOperations", + "OffersOperations", + "Operations", + "PublishersOperations", + "SecuritySettingsOperations", + "SkusOperations", "StorageContainersOperations", + "UpdateRunsOperations", + "UpdateSummariesOperations", + "UpdatesOperations", "VirtualHardDisksOperations", "VirtualMachineInstancesOperations", "HybridIdentityMetadataOperations", diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_arc_settings_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_arc_settings_operations.py new file mode 100644 index 000000000000..cc71b3deb7f7 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_arc_settings_operations.py @@ -0,0 +1,1279 @@ +# pylint: disable=too-many-lines,too-many-statements +# 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 io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_cluster_request( + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, cluster_name: str, arc_setting_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "arcSettingName": _SERIALIZER.url("arc_setting_name", arc_setting_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_request( + resource_group_name: str, cluster_name: str, arc_setting_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "arcSettingName": _SERIALIZER.url("arc_setting_name", arc_setting_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, cluster_name: str, arc_setting_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "arcSettingName": _SERIALIZER.url("arc_setting_name", arc_setting_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, cluster_name: str, arc_setting_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "arcSettingName": _SERIALIZER.url("arc_setting_name", arc_setting_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_generate_password_request( + resource_group_name: str, cluster_name: str, arc_setting_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/generatePassword", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "arcSettingName": _SERIALIZER.url("arc_setting_name", arc_setting_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_identity_request( + resource_group_name: str, cluster_name: str, arc_setting_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/createArcIdentity", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "arcSettingName": _SERIALIZER.url("arc_setting_name", arc_setting_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_consent_and_install_default_extensions_request( # pylint: disable=name-too-long + resource_group_name: str, cluster_name: str, arc_setting_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/consentAndInstallDefaultExtensions", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "arcSettingName": _SERIALIZER.url("arc_setting_name", arc_setting_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_initialize_disable_process_request( + resource_group_name: str, cluster_name: str, arc_setting_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/initializeDisableProcess", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "arcSettingName": _SERIALIZER.url("arc_setting_name", arc_setting_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class ArcSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.azurestackhci.AzureStackHCIClient`'s + :attr:`arc_settings` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_cluster( + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> Iterable["_models.ArcSetting"]: + """Get ArcSetting resources of HCI Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :return: An iterator like instance of either ArcSetting or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.ArcSetting] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ArcSettingList] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_cluster_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ArcSettingList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, resource_group_name: str, cluster_name: str, arc_setting_name: str, **kwargs: Any + ) -> _models.ArcSetting: + """Get ArcSetting resource details of HCI Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting + information. Required. + :type arc_setting_name: str + :return: ArcSetting or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.ArcSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ArcSetting] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + arc_setting_name=arc_setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ArcSetting", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create( + self, + resource_group_name: str, + cluster_name: str, + arc_setting_name: str, + arc_setting: _models.ArcSetting, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ArcSetting: + """Create ArcSetting for HCI cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting + information. Required. + :type arc_setting_name: str + :param arc_setting: Parameters supplied to the Create ArcSetting resource for this HCI cluster. + Required. + :type arc_setting: ~azure.mgmt.azurestackhci.models.ArcSetting + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ArcSetting or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.ArcSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + cluster_name: str, + arc_setting_name: str, + arc_setting: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ArcSetting: + """Create ArcSetting for HCI cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting + information. Required. + :type arc_setting_name: str + :param arc_setting: Parameters supplied to the Create ArcSetting resource for this HCI cluster. + Required. + :type arc_setting: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ArcSetting or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.ArcSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + cluster_name: str, + arc_setting_name: str, + arc_setting: Union[_models.ArcSetting, IO[bytes]], + **kwargs: Any + ) -> _models.ArcSetting: + """Create ArcSetting for HCI cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting + information. Required. + :type arc_setting_name: str + :param arc_setting: Parameters supplied to the Create ArcSetting resource for this HCI cluster. + Is either a ArcSetting type or a IO[bytes] type. Required. + :type arc_setting: ~azure.mgmt.azurestackhci.models.ArcSetting or IO[bytes] + :return: ArcSetting or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.ArcSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ArcSetting] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(arc_setting, (IOBase, bytes)): + _content = arc_setting + else: + _json = self._serialize.body(arc_setting, "ArcSetting") + + _request = build_create_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + arc_setting_name=arc_setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ArcSetting", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_group_name: str, + cluster_name: str, + arc_setting_name: str, + arc_setting: _models.ArcSettingsPatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ArcSetting: + """Update ArcSettings for HCI cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting + information. Required. + :type arc_setting_name: str + :param arc_setting: ArcSettings parameters that needs to be updated. Required. + :type arc_setting: ~azure.mgmt.azurestackhci.models.ArcSettingsPatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ArcSetting or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.ArcSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + cluster_name: str, + arc_setting_name: str, + arc_setting: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ArcSetting: + """Update ArcSettings for HCI cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting + information. Required. + :type arc_setting_name: str + :param arc_setting: ArcSettings parameters that needs to be updated. Required. + :type arc_setting: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ArcSetting or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.ArcSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + cluster_name: str, + arc_setting_name: str, + arc_setting: Union[_models.ArcSettingsPatch, IO[bytes]], + **kwargs: Any + ) -> _models.ArcSetting: + """Update ArcSettings for HCI cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting + information. Required. + :type arc_setting_name: str + :param arc_setting: ArcSettings parameters that needs to be updated. Is either a + ArcSettingsPatch type or a IO[bytes] type. Required. + :type arc_setting: ~azure.mgmt.azurestackhci.models.ArcSettingsPatch or IO[bytes] + :return: ArcSetting or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.ArcSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ArcSetting] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(arc_setting, (IOBase, bytes)): + _content = arc_setting + else: + _json = self._serialize.body(arc_setting, "ArcSettingsPatch") + + _request = build_update_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + arc_setting_name=arc_setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ArcSetting", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _delete_initial( + self, resource_group_name: str, cluster_name: str, arc_setting_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + arc_setting_name=arc_setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, cluster_name: str, arc_setting_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Delete ArcSetting resource details of HCI Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting + information. Required. + :type arc_setting_name: str + :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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + arc_setting_name=arc_setting_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def generate_password( + self, resource_group_name: str, cluster_name: str, arc_setting_name: str, **kwargs: Any + ) -> _models.PasswordCredential: + """Generate password for arc settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting + information. Required. + :type arc_setting_name: str + :return: PasswordCredential or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.PasswordCredential + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PasswordCredential] = kwargs.pop("cls", None) + + _request = build_generate_password_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + arc_setting_name=arc_setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PasswordCredential", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_identity_initial( + self, resource_group_name: str, cluster_name: str, arc_setting_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_create_identity_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + arc_setting_name=arc_setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_create_identity( + self, resource_group_name: str, cluster_name: str, arc_setting_name: str, **kwargs: Any + ) -> LROPoller[_models.ArcIdentityResponse]: + """Create Aad identity for arc settings. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting + information. Required. + :type arc_setting_name: str + :return: An instance of LROPoller that returns either ArcIdentityResponse or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.ArcIdentityResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ArcIdentityResponse] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_identity_initial( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + arc_setting_name=arc_setting_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ArcIdentityResponse", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ArcIdentityResponse].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ArcIdentityResponse]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def consent_and_install_default_extensions( + self, resource_group_name: str, cluster_name: str, arc_setting_name: str, **kwargs: Any + ) -> _models.ArcSetting: + """Add consent time for default extensions and initiate extensions installation. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting + information. Required. + :type arc_setting_name: str + :return: ArcSetting or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.ArcSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ArcSetting] = kwargs.pop("cls", None) + + _request = build_consent_and_install_default_extensions_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + arc_setting_name=arc_setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ArcSetting", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _initialize_disable_process_initial( + self, resource_group_name: str, cluster_name: str, arc_setting_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_initialize_disable_process_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + arc_setting_name=arc_setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_initialize_disable_process( + self, resource_group_name: str, cluster_name: str, arc_setting_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Initializes ARC Disable process on the cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting + information. Required. + :type arc_setting_name: str + :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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._initialize_disable_process_initial( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + arc_setting_name=arc_setting_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_clusters_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_clusters_operations.py new file mode 100644 index 000000000000..019627d8254a --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_clusters_operations.py @@ -0,0 +1,1423 @@ +# pylint: disable=too-many-lines,too-many-statements +# 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 io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/clusters") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_request( + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_upload_certificate_request( + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/uploadCertificate", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_identity_request( + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/createClusterIdentity", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_extend_software_assurance_benefit_request( # pylint: disable=name-too-long + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/extendSoftwareAssuranceBenefit", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class ClustersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.azurestackhci.AzureStackHCIClient`'s + :attr:`clusters` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.Cluster"]: + """List all HCI clusters in a subscription. + + :return: An iterator like instance of either Cluster or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ClusterList] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ClusterList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Cluster"]: + """List all HCI clusters in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of either Cluster or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ClusterList] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ClusterList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> _models.Cluster: + """Get HCI cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :return: Cluster or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.Cluster + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.Cluster] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Cluster", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def create( + self, + resource_group_name: str, + cluster_name: str, + cluster: _models.Cluster, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Cluster: + """Create an HCI cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param cluster: Details of the HCI cluster. Required. + :type cluster: ~azure.mgmt.azurestackhci.models.Cluster + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Cluster or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.Cluster + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + cluster_name: str, + cluster: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Cluster: + """Create an HCI cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param cluster: Details of the HCI cluster. Required. + :type cluster: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: Cluster or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.Cluster + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, resource_group_name: str, cluster_name: str, cluster: Union[_models.Cluster, IO[bytes]], **kwargs: Any + ) -> _models.Cluster: + """Create an HCI cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param cluster: Details of the HCI cluster. Is either a Cluster type or a IO[bytes] type. + Required. + :type cluster: ~azure.mgmt.azurestackhci.models.Cluster or IO[bytes] + :return: Cluster or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.Cluster + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Cluster] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(cluster, (IOBase, bytes)): + _content = cluster + else: + _json = self._serialize.body(cluster, "Cluster") + + _request = build_create_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Cluster", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_group_name: str, + cluster_name: str, + cluster: _models.ClusterPatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Cluster: + """Update an HCI cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param cluster: Details of the HCI cluster. Required. + :type cluster: ~azure.mgmt.azurestackhci.models.ClusterPatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Cluster or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.Cluster + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + cluster_name: str, + cluster: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Cluster: + """Update an HCI cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param cluster: Details of the HCI cluster. Required. + :type cluster: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: Cluster or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.Cluster + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + cluster_name: str, + cluster: Union[_models.ClusterPatch, IO[bytes]], + **kwargs: Any + ) -> _models.Cluster: + """Update an HCI cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param cluster: Details of the HCI cluster. Is either a ClusterPatch type or a IO[bytes] type. + Required. + :type cluster: ~azure.mgmt.azurestackhci.models.ClusterPatch or IO[bytes] + :return: Cluster or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.Cluster + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Cluster] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(cluster, (IOBase, bytes)): + _content = cluster + else: + _json = self._serialize.body(cluster, "ClusterPatch") + + _request = build_update_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Cluster", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _delete_initial(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> LROPoller[None]: + """Delete an HCI cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + def _upload_certificate_initial( + self, + resource_group_name: str, + cluster_name: str, + upload_certificate_request: Union[_models.UploadCertificateRequest, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(upload_certificate_request, (IOBase, bytes)): + _content = upload_certificate_request + else: + _json = self._serialize.body(upload_certificate_request, "UploadCertificateRequest") + + _request = build_upload_certificate_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_upload_certificate( + self, + resource_group_name: str, + cluster_name: str, + upload_certificate_request: _models.UploadCertificateRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Upload certificate. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param upload_certificate_request: Upload certificate request. Required. + :type upload_certificate_request: ~azure.mgmt.azurestackhci.models.UploadCertificateRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_upload_certificate( + self, + resource_group_name: str, + cluster_name: str, + upload_certificate_request: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Upload certificate. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param upload_certificate_request: Upload certificate request. Required. + :type upload_certificate_request: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_upload_certificate( + self, + resource_group_name: str, + cluster_name: str, + upload_certificate_request: Union[_models.UploadCertificateRequest, IO[bytes]], + **kwargs: Any + ) -> LROPoller[None]: + """Upload certificate. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param upload_certificate_request: Upload certificate request. Is either a + UploadCertificateRequest type or a IO[bytes] type. Required. + :type upload_certificate_request: ~azure.mgmt.azurestackhci.models.UploadCertificateRequest or + IO[bytes] + :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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._upload_certificate_initial( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + upload_certificate_request=upload_certificate_request, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + def _create_identity_initial(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_create_identity_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_create_identity( + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> LROPoller[_models.ClusterIdentityResponse]: + """Create cluster identity. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :return: An instance of LROPoller that returns either ClusterIdentityResponse or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.ClusterIdentityResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ClusterIdentityResponse] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_identity_initial( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ClusterIdentityResponse", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ClusterIdentityResponse].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ClusterIdentityResponse]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _extend_software_assurance_benefit_initial( # pylint: disable=name-too-long + self, + resource_group_name: str, + cluster_name: str, + software_assurance_change_request: Union[_models.SoftwareAssuranceChangeRequest, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(software_assurance_change_request, (IOBase, bytes)): + _content = software_assurance_change_request + else: + _json = self._serialize.body(software_assurance_change_request, "SoftwareAssuranceChangeRequest") + + _request = build_extend_software_assurance_benefit_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_extend_software_assurance_benefit( + self, + resource_group_name: str, + cluster_name: str, + software_assurance_change_request: _models.SoftwareAssuranceChangeRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Cluster]: + """Extends Software Assurance Benefit to a cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param software_assurance_change_request: Software Assurance Change Request Payload. Required. + :type software_assurance_change_request: + ~azure.mgmt.azurestackhci.models.SoftwareAssuranceChangeRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either Cluster or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_extend_software_assurance_benefit( + self, + resource_group_name: str, + cluster_name: str, + software_assurance_change_request: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Cluster]: + """Extends Software Assurance Benefit to a cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param software_assurance_change_request: Software Assurance Change Request Payload. Required. + :type software_assurance_change_request: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either Cluster or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_extend_software_assurance_benefit( + self, + resource_group_name: str, + cluster_name: str, + software_assurance_change_request: Union[_models.SoftwareAssuranceChangeRequest, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Cluster]: + """Extends Software Assurance Benefit to a cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param software_assurance_change_request: Software Assurance Change Request Payload. Is either + a SoftwareAssuranceChangeRequest type or a IO[bytes] type. Required. + :type software_assurance_change_request: + ~azure.mgmt.azurestackhci.models.SoftwareAssuranceChangeRequest or IO[bytes] + :return: An instance of LROPoller that returns either Cluster or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Cluster] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Cluster] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._extend_software_assurance_benefit_initial( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + software_assurance_change_request=software_assurance_change_request, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Cluster", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Cluster].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Cluster]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_deployment_settings_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_deployment_settings_operations.py new file mode 100644 index 000000000000..d72786ba31a7 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_deployment_settings_operations.py @@ -0,0 +1,693 @@ +# pylint: disable=too-many-lines,too-many-statements +# 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 io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_clusters_request( + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/deploymentSettings", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, + cluster_name: str, + subscription_id: str, + deployment_settings_name: str = "default", + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/deploymentSettings/{deploymentSettingsName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "deploymentSettingsName": _SERIALIZER.url( + "deployment_settings_name", deployment_settings_name, "str", pattern=r"^[a-zA-Z0-9-]{3,24}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + cluster_name: str, + subscription_id: str, + deployment_settings_name: str = "default", + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/deploymentSettings/{deploymentSettingsName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "deploymentSettingsName": _SERIALIZER.url( + "deployment_settings_name", deployment_settings_name, "str", pattern=r"^[a-zA-Z0-9-]{3,24}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + cluster_name: str, + subscription_id: str, + deployment_settings_name: str = "default", + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/deploymentSettings/{deploymentSettingsName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "deploymentSettingsName": _SERIALIZER.url( + "deployment_settings_name", deployment_settings_name, "str", pattern=r"^[a-zA-Z0-9-]{3,24}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class DeploymentSettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.azurestackhci.AzureStackHCIClient`'s + :attr:`deployment_settings` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_clusters( + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> Iterable["_models.DeploymentSetting"]: + """List DeploymentSetting resources by Clusters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :return: An iterator like instance of either DeploymentSetting or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.DeploymentSetting] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.DeploymentSettingListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_clusters_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("DeploymentSettingListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, resource_group_name: str, cluster_name: str, deployment_settings_name: str = "default", **kwargs: Any + ) -> _models.DeploymentSetting: + """Get a DeploymentSetting. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param deployment_settings_name: Name of Deployment Setting. Default value is "default". + :type deployment_settings_name: str + :return: DeploymentSetting or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.DeploymentSetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.DeploymentSetting] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + deployment_settings_name=deployment_settings_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DeploymentSetting", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + cluster_name: str, + resource: Union[_models.DeploymentSetting, IO[bytes]], + deployment_settings_name: str = "default", + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IOBase, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "DeploymentSetting") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + deployment_settings_name=deployment_settings_name, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + cluster_name: str, + resource: _models.DeploymentSetting, + deployment_settings_name: str = "default", + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentSetting]: + """Create a DeploymentSetting. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param resource: Resource create parameters. Required. + :type resource: ~azure.mgmt.azurestackhci.models.DeploymentSetting + :param deployment_settings_name: Name of Deployment Setting. Default value is "default". + :type deployment_settings_name: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either DeploymentSetting or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.DeploymentSetting] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + cluster_name: str, + resource: IO[bytes], + deployment_settings_name: str = "default", + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DeploymentSetting]: + """Create a DeploymentSetting. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param resource: Resource create parameters. Required. + :type resource: IO[bytes] + :param deployment_settings_name: Name of Deployment Setting. Default value is "default". + :type deployment_settings_name: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either DeploymentSetting or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.DeploymentSetting] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + cluster_name: str, + resource: Union[_models.DeploymentSetting, IO[bytes]], + deployment_settings_name: str = "default", + **kwargs: Any + ) -> LROPoller[_models.DeploymentSetting]: + """Create a DeploymentSetting. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param resource: Resource create parameters. Is either a DeploymentSetting type or a IO[bytes] + type. Required. + :type resource: ~azure.mgmt.azurestackhci.models.DeploymentSetting or IO[bytes] + :param deployment_settings_name: Name of Deployment Setting. Default value is "default". + :type deployment_settings_name: str + :return: An instance of LROPoller that returns either DeploymentSetting or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.DeploymentSetting] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DeploymentSetting] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + resource=resource, + deployment_settings_name=deployment_settings_name, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DeploymentSetting", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.DeploymentSetting].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.DeploymentSetting]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, cluster_name: str, deployment_settings_name: str = "default", **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + deployment_settings_name=deployment_settings_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, cluster_name: str, deployment_settings_name: str = "default", **kwargs: Any + ) -> LROPoller[None]: + """Delete a DeploymentSetting. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param deployment_settings_name: Name of Deployment Setting. Default value is "default". + :type deployment_settings_name: str + :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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + deployment_settings_name=deployment_settings_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_edge_devices_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_edge_devices_operations.py new file mode 100644 index 000000000000..1858f1f44d3d --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_edge_devices_operations.py @@ -0,0 +1,831 @@ +# pylint: disable=too-many-lines,too-many-statements +# 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 io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(resource_uri: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.AzureStackHCI/edgeDevices") + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(resource_uri: str, edge_device_name: str = "default", **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.AzureStackHCI/edgeDevices/{edgeDeviceName}") + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), + "edgeDeviceName": _SERIALIZER.url("edge_device_name", edge_device_name, "str", pattern=r"^[a-zA-Z0-9-]{3,24}$"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request(resource_uri: str, edge_device_name: str = "default", **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.AzureStackHCI/edgeDevices/{edgeDeviceName}") + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), + "edgeDeviceName": _SERIALIZER.url("edge_device_name", edge_device_name, "str", pattern=r"^[a-zA-Z0-9-]{3,24}$"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request(resource_uri: str, edge_device_name: str = "default", **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/{resourceUri}/providers/Microsoft.AzureStackHCI/edgeDevices/{edgeDeviceName}") + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), + "edgeDeviceName": _SERIALIZER.url("edge_device_name", edge_device_name, "str", pattern=r"^[a-zA-Z0-9-]{3,24}$"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_validate_request(resource_uri: str, edge_device_name: str = "default", **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/{resourceUri}/providers/Microsoft.AzureStackHCI/edgeDevices/{edgeDeviceName}/validate" + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), + "edgeDeviceName": _SERIALIZER.url("edge_device_name", edge_device_name, "str", pattern=r"^[a-zA-Z0-9-]{3,24}$"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class EdgeDevicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.azurestackhci.AzureStackHCIClient`'s + :attr:`edge_devices` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, resource_uri: str, **kwargs: Any) -> Iterable["_models.EdgeDevice"]: + """List EdgeDevice resources by parent. + + :param resource_uri: The fully qualified Azure Resource manager identifier of the resource. + Required. + :type resource_uri: str + :return: An iterator like instance of either EdgeDevice or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.EdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.EdgeDeviceListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_uri=resource_uri, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("EdgeDeviceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get(self, resource_uri: str, edge_device_name: str = "default", **kwargs: Any) -> _models.EdgeDevice: + """Get a EdgeDevice. + + :param resource_uri: The fully qualified Azure Resource manager identifier of the resource. + Required. + :type resource_uri: str + :param edge_device_name: Name of Device. Default value is "default". + :type edge_device_name: str + :return: EdgeDevice or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.EdgeDevice + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.EdgeDevice] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_uri=resource_uri, + edge_device_name=edge_device_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("EdgeDevice", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_uri: str, + resource: Union[_models.EdgeDevice, IO[bytes]], + edge_device_name: str = "default", + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IOBase, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "EdgeDevice") + + _request = build_create_or_update_request( + resource_uri=resource_uri, + edge_device_name=edge_device_name, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_uri: str, + resource: _models.EdgeDevice, + edge_device_name: str = "default", + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.EdgeDevice]: + """Create a EdgeDevice. + + :param resource_uri: The fully qualified Azure Resource manager identifier of the resource. + Required. + :type resource_uri: str + :param resource: Resource create parameters. Required. + :type resource: ~azure.mgmt.azurestackhci.models.EdgeDevice + :param edge_device_name: Name of Device. Default value is "default". + :type edge_device_name: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either EdgeDevice or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.EdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_uri: str, + resource: IO[bytes], + edge_device_name: str = "default", + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.EdgeDevice]: + """Create a EdgeDevice. + + :param resource_uri: The fully qualified Azure Resource manager identifier of the resource. + Required. + :type resource_uri: str + :param resource: Resource create parameters. Required. + :type resource: IO[bytes] + :param edge_device_name: Name of Device. Default value is "default". + :type edge_device_name: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either EdgeDevice or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.EdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_uri: str, + resource: Union[_models.EdgeDevice, IO[bytes]], + edge_device_name: str = "default", + **kwargs: Any + ) -> LROPoller[_models.EdgeDevice]: + """Create a EdgeDevice. + + :param resource_uri: The fully qualified Azure Resource manager identifier of the resource. + Required. + :type resource_uri: str + :param resource: Resource create parameters. Is either a EdgeDevice type or a IO[bytes] type. + Required. + :type resource: ~azure.mgmt.azurestackhci.models.EdgeDevice or IO[bytes] + :param edge_device_name: Name of Device. Default value is "default". + :type edge_device_name: str + :return: An instance of LROPoller that returns either EdgeDevice or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.EdgeDevice] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.EdgeDevice] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_uri=resource_uri, + resource=resource, + edge_device_name=edge_device_name, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("EdgeDevice", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.EdgeDevice].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.EdgeDevice]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial(self, resource_uri: str, edge_device_name: str = "default", **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_uri=resource_uri, + edge_device_name=edge_device_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete(self, resource_uri: str, edge_device_name: str = "default", **kwargs: Any) -> LROPoller[None]: + """Delete a EdgeDevice. + + :param resource_uri: The fully qualified Azure Resource manager identifier of the resource. + Required. + :type resource_uri: str + :param edge_device_name: Name of Device. Default value is "default". + :type edge_device_name: str + :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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_uri=resource_uri, + edge_device_name=edge_device_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + def _validate_initial( + self, + resource_uri: str, + validate_request: Union[_models.ValidateRequest, IO[bytes]], + edge_device_name: str = "default", + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(validate_request, (IOBase, bytes)): + _content = validate_request + else: + _json = self._serialize.body(validate_request, "ValidateRequest") + + _request = build_validate_request( + resource_uri=resource_uri, + edge_device_name=edge_device_name, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_validate( + self, + resource_uri: str, + validate_request: _models.ValidateRequest, + edge_device_name: str = "default", + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ValidateResponse]: + """A long-running resource action. + + :param resource_uri: The fully qualified Azure Resource manager identifier of the resource. + Required. + :type resource_uri: str + :param validate_request: The content of the action request. Required. + :type validate_request: ~azure.mgmt.azurestackhci.models.ValidateRequest + :param edge_device_name: Name of Device. Default value is "default". + :type edge_device_name: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either ValidateResponse or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.ValidateResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_validate( + self, + resource_uri: str, + validate_request: IO[bytes], + edge_device_name: str = "default", + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ValidateResponse]: + """A long-running resource action. + + :param resource_uri: The fully qualified Azure Resource manager identifier of the resource. + Required. + :type resource_uri: str + :param validate_request: The content of the action request. Required. + :type validate_request: IO[bytes] + :param edge_device_name: Name of Device. Default value is "default". + :type edge_device_name: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either ValidateResponse or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.ValidateResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_validate( + self, + resource_uri: str, + validate_request: Union[_models.ValidateRequest, IO[bytes]], + edge_device_name: str = "default", + **kwargs: Any + ) -> LROPoller[_models.ValidateResponse]: + """A long-running resource action. + + :param resource_uri: The fully qualified Azure Resource manager identifier of the resource. + Required. + :type resource_uri: str + :param validate_request: The content of the action request. Is either a ValidateRequest type or + a IO[bytes] type. Required. + :type validate_request: ~azure.mgmt.azurestackhci.models.ValidateRequest or IO[bytes] + :param edge_device_name: Name of Device. Default value is "default". + :type edge_device_name: str + :return: An instance of LROPoller that returns either ValidateResponse or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.ValidateResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ValidateResponse] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._validate_initial( + resource_uri=resource_uri, + validate_request=validate_request, + edge_device_name=edge_device_name, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ValidateResponse", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.ValidateResponse].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.ValidateResponse]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_extensions_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_extensions_operations.py new file mode 100644 index 000000000000..a08a49e92da8 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_extensions_operations.py @@ -0,0 +1,1233 @@ +# pylint: disable=too-many-lines,too-many-statements +# 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 io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_arc_setting_request( + resource_group_name: str, cluster_name: str, arc_setting_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "arcSettingName": _SERIALIZER.url("arc_setting_name", arc_setting_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, + cluster_name: str, + arc_setting_name: str, + extension_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions/{extensionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "arcSettingName": _SERIALIZER.url("arc_setting_name", arc_setting_name, "str"), + "extensionName": _SERIALIZER.url("extension_name", extension_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_request( + resource_group_name: str, + cluster_name: str, + arc_setting_name: str, + extension_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions/{extensionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "arcSettingName": _SERIALIZER.url("arc_setting_name", arc_setting_name, "str"), + "extensionName": _SERIALIZER.url("extension_name", extension_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, + cluster_name: str, + arc_setting_name: str, + extension_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions/{extensionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "arcSettingName": _SERIALIZER.url("arc_setting_name", arc_setting_name, "str"), + "extensionName": _SERIALIZER.url("extension_name", extension_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + cluster_name: str, + arc_setting_name: str, + extension_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions/{extensionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "arcSettingName": _SERIALIZER.url("arc_setting_name", arc_setting_name, "str"), + "extensionName": _SERIALIZER.url("extension_name", extension_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_upgrade_request( + resource_group_name: str, + cluster_name: str, + arc_setting_name: str, + extension_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions/{extensionName}/upgrade", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "arcSettingName": _SERIALIZER.url("arc_setting_name", arc_setting_name, "str"), + "extensionName": _SERIALIZER.url("extension_name", extension_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class ExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.azurestackhci.AzureStackHCIClient`'s + :attr:`extensions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_arc_setting( + self, resource_group_name: str, cluster_name: str, arc_setting_name: str, **kwargs: Any + ) -> Iterable["_models.Extension"]: + """List all Extensions under ArcSetting resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting + information. Required. + :type arc_setting_name: str + :return: An iterator like instance of either Extension or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ExtensionList] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_arc_setting_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + arc_setting_name=arc_setting_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ExtensionList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, resource_group_name: str, cluster_name: str, arc_setting_name: str, extension_name: str, **kwargs: Any + ) -> _models.Extension: + """Get particular Arc Extension of HCI Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting + information. Required. + :type arc_setting_name: str + :param extension_name: The name of the machine extension. Required. + :type extension_name: str + :return: Extension or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.Extension + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + arc_setting_name=arc_setting_name, + extension_name=extension_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Extension", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_initial( + self, + resource_group_name: str, + cluster_name: str, + arc_setting_name: str, + extension_name: str, + extension: Union[_models.Extension, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(extension, (IOBase, bytes)): + _content = extension + else: + _json = self._serialize.body(extension, "Extension") + + _request = build_create_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + arc_setting_name=arc_setting_name, + extension_name=extension_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create( + self, + resource_group_name: str, + cluster_name: str, + arc_setting_name: str, + extension_name: str, + extension: _models.Extension, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Extension]: + """Create Extension for HCI cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting + information. Required. + :type arc_setting_name: str + :param extension_name: The name of the machine extension. Required. + :type extension_name: str + :param extension: Details of the Machine Extension to be created. Required. + :type extension: ~azure.mgmt.azurestackhci.models.Extension + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either Extension or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + cluster_name: str, + arc_setting_name: str, + extension_name: str, + extension: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Extension]: + """Create Extension for HCI cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting + information. Required. + :type arc_setting_name: str + :param extension_name: The name of the machine extension. Required. + :type extension_name: str + :param extension: Details of the Machine Extension to be created. Required. + :type extension: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either Extension or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + cluster_name: str, + arc_setting_name: str, + extension_name: str, + extension: Union[_models.Extension, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Extension]: + """Create Extension for HCI cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting + information. Required. + :type arc_setting_name: str + :param extension_name: The name of the machine extension. Required. + :type extension_name: str + :param extension: Details of the Machine Extension to be created. Is either a Extension type or + a IO[bytes] type. Required. + :type extension: ~azure.mgmt.azurestackhci.models.Extension or IO[bytes] + :return: An instance of LROPoller that returns either Extension or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + arc_setting_name=arc_setting_name, + extension_name=extension_name, + extension=extension, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Extension", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Extension].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Extension]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _update_initial( + self, + resource_group_name: str, + cluster_name: str, + arc_setting_name: str, + extension_name: str, + extension: Union[_models.ExtensionPatch, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(extension, (IOBase, bytes)): + _content = extension + else: + _json = self._serialize.body(extension, "ExtensionPatch") + + _request = build_update_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + arc_setting_name=arc_setting_name, + extension_name=extension_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + cluster_name: str, + arc_setting_name: str, + extension_name: str, + extension: _models.ExtensionPatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Extension]: + """Update Extension for HCI cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting + information. Required. + :type arc_setting_name: str + :param extension_name: The name of the machine extension. Required. + :type extension_name: str + :param extension: Details of the Machine Extension to be created. Required. + :type extension: ~azure.mgmt.azurestackhci.models.ExtensionPatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either Extension or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + cluster_name: str, + arc_setting_name: str, + extension_name: str, + extension: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.Extension]: + """Update Extension for HCI cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting + information. Required. + :type arc_setting_name: str + :param extension_name: The name of the machine extension. Required. + :type extension_name: str + :param extension: Details of the Machine Extension to be created. Required. + :type extension: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either Extension or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + cluster_name: str, + arc_setting_name: str, + extension_name: str, + extension: Union[_models.ExtensionPatch, IO[bytes]], + **kwargs: Any + ) -> LROPoller[_models.Extension]: + """Update Extension for HCI cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting + information. Required. + :type arc_setting_name: str + :param extension_name: The name of the machine extension. Required. + :type extension_name: str + :param extension: Details of the Machine Extension to be created. Is either a ExtensionPatch + type or a IO[bytes] type. Required. + :type extension: ~azure.mgmt.azurestackhci.models.ExtensionPatch or IO[bytes] + :return: An instance of LROPoller that returns either Extension or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.Extension] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Extension] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + arc_setting_name=arc_setting_name, + extension_name=extension_name, + extension=extension, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("Extension", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "original-uri"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.Extension].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.Extension]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, cluster_name: str, arc_setting_name: str, extension_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + arc_setting_name=arc_setting_name, + extension_name=extension_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, cluster_name: str, arc_setting_name: str, extension_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Delete particular Arc Extension of HCI Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting + information. Required. + :type arc_setting_name: str + :param extension_name: The name of the machine extension. Required. + :type extension_name: str + :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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + arc_setting_name=arc_setting_name, + extension_name=extension_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + def _upgrade_initial( + self, + resource_group_name: str, + cluster_name: str, + arc_setting_name: str, + extension_name: str, + extension_upgrade_parameters: Union[_models.ExtensionUpgradeParameters, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(extension_upgrade_parameters, (IOBase, bytes)): + _content = extension_upgrade_parameters + else: + _json = self._serialize.body(extension_upgrade_parameters, "ExtensionUpgradeParameters") + + _request = build_upgrade_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + arc_setting_name=arc_setting_name, + extension_name=extension_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_upgrade( + self, + resource_group_name: str, + cluster_name: str, + arc_setting_name: str, + extension_name: str, + extension_upgrade_parameters: _models.ExtensionUpgradeParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Upgrade a particular Arc Extension of HCI Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting + information. Required. + :type arc_setting_name: str + :param extension_name: The name of the machine extension. Required. + :type extension_name: str + :param extension_upgrade_parameters: Parameters supplied to the Upgrade Extensions operation. + Required. + :type extension_upgrade_parameters: ~azure.mgmt.azurestackhci.models.ExtensionUpgradeParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_upgrade( + self, + resource_group_name: str, + cluster_name: str, + arc_setting_name: str, + extension_name: str, + extension_upgrade_parameters: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Upgrade a particular Arc Extension of HCI Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting + information. Required. + :type arc_setting_name: str + :param extension_name: The name of the machine extension. Required. + :type extension_name: str + :param extension_upgrade_parameters: Parameters supplied to the Upgrade Extensions operation. + Required. + :type extension_upgrade_parameters: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_upgrade( + self, + resource_group_name: str, + cluster_name: str, + arc_setting_name: str, + extension_name: str, + extension_upgrade_parameters: Union[_models.ExtensionUpgradeParameters, IO[bytes]], + **kwargs: Any + ) -> LROPoller[None]: + """Upgrade a particular Arc Extension of HCI Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param arc_setting_name: The name of the proxy resource holding details of HCI ArcSetting + information. Required. + :type arc_setting_name: str + :param extension_name: The name of the machine extension. Required. + :type extension_name: str + :param extension_upgrade_parameters: Parameters supplied to the Upgrade Extensions operation. + Is either a ExtensionUpgradeParameters type or a IO[bytes] type. Required. + :type extension_upgrade_parameters: ~azure.mgmt.azurestackhci.models.ExtensionUpgradeParameters + or IO[bytes] + :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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._upgrade_initial( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + arc_setting_name=arc_setting_name, + extension_name=extension_name, + extension_upgrade_parameters=extension_upgrade_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_gallery_images_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_gallery_images_operations.py index 08e02d73cff3..37ce63ffd088 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_gallery_images_operations.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_gallery_images_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, 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.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +50,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -85,7 +90,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -128,7 +133,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -168,7 +173,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -209,7 +214,7 @@ def build_list_request(resource_group_name: str, subscription_id: str, **kwargs: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -239,7 +244,7 @@ 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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -287,12 +292,11 @@ def get(self, resource_group_name: str, gallery_image_name: str, **kwargs: Any) :type resource_group_name: str :param gallery_image_name: Name of the gallery image. Required. :type gallery_image_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: GalleryImages or the result of cls(response) :rtype: ~azure.mgmt.azurestackhci.models.GalleryImages :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -306,21 +310,19 @@ def get(self, resource_group_name: str, gallery_image_name: str, **kwargs: Any) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.GalleryImages] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, gallery_image_name=gallery_image_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -330,25 +332,21 @@ def get(self, resource_group_name: str, gallery_image_name: str, **kwargs: Any) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("GalleryImages", pipeline_response) + deserialized = self._deserialize("GalleryImages", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/galleryImages/{galleryImageName}" - } + return deserialized # type: ignore def _create_or_update_initial( self, resource_group_name: str, gallery_image_name: str, - gallery_images: Union[_models.GalleryImages, IO], + gallery_images: Union[_models.GalleryImages, IO[bytes]], **kwargs: Any - ) -> _models.GalleryImages: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -361,7 +359,7 @@ def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.GalleryImages] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -371,7 +369,7 @@ def _create_or_update_initial( else: _json = self._serialize.body(gallery_images, "GalleryImages") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, gallery_image_name=gallery_image_name, subscription_id=self._config.subscription_id, @@ -379,40 +377,35 @@ def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("GalleryImages", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("GalleryImages", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/galleryImages/{galleryImageName}" - } - @overload def begin_create_or_update( self, @@ -436,14 +429,6 @@ def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either GalleryImages or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.GalleryImages] @@ -455,7 +440,7 @@ def begin_create_or_update( self, resource_group_name: str, gallery_image_name: str, - gallery_images: IO, + gallery_images: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -469,18 +454,10 @@ def begin_create_or_update( :param gallery_image_name: Name of the gallery image. Required. :type gallery_image_name: str :param gallery_images: Required. - :type gallery_images: IO + :type gallery_images: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either GalleryImages or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.GalleryImages] @@ -492,7 +469,7 @@ def begin_create_or_update( self, resource_group_name: str, gallery_image_name: str, - gallery_images: Union[_models.GalleryImages, IO], + gallery_images: Union[_models.GalleryImages, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.GalleryImages]: """The operation to create or update a gallery image. Please note some properties can be set only @@ -503,19 +480,8 @@ def begin_create_or_update( :type resource_group_name: str :param gallery_image_name: Name of the gallery image. Required. :type gallery_image_name: str - :param gallery_images: Is either a GalleryImages type or a IO type. Required. - :type gallery_images: ~azure.mgmt.azurestackhci.models.GalleryImages or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param gallery_images: Is either a GalleryImages type or a IO[bytes] type. Required. + :type gallery_images: ~azure.mgmt.azurestackhci.models.GalleryImages or IO[bytes] :return: An instance of LROPoller that returns either GalleryImages or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.GalleryImages] @@ -542,12 +508,13 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("GalleryImages", pipeline_response) + deserialized = self._deserialize("GalleryImages", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -559,22 +526,18 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.GalleryImages].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/galleryImages/{galleryImageName}" - } + return LROPoller[_models.GalleryImages]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, gallery_image_name: str, **kwargs: Any - ) -> None: - error_map = { + def _delete_initial(self, resource_group_name: str, gallery_image_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -586,28 +549,31 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, gallery_image_name=gallery_image_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) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -616,12 +582,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/galleryImages/{galleryImageName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete(self, resource_group_name: str, gallery_image_name: str, **kwargs: Any) -> LROPoller[None]: @@ -632,14 +598,6 @@ def begin_delete(self, resource_group_name: str, gallery_image_name: str, **kwar :type resource_group_name: str :param gallery_image_name: Name of the gallery image. Required. :type gallery_image_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: @@ -653,7 +611,7 @@ def begin_delete(self, resource_group_name: str, gallery_image_name: str, **kwar lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, gallery_image_name=gallery_image_name, api_version=api_version, @@ -662,11 +620,12 @@ def begin_delete(self, resource_group_name: str, gallery_image_name: str, **kwar params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -677,26 +636,22 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/galleryImages/{galleryImageName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _update_initial( self, resource_group_name: str, gallery_image_name: str, - gallery_images: Union[_models.GalleryImagesUpdateRequest, IO], + gallery_images: Union[_models.GalleryImagesUpdateRequest, IO[bytes]], **kwargs: Any - ) -> Optional[_models.GalleryImages]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -709,7 +664,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.GalleryImages]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -719,7 +674,7 @@ def _update_initial( else: _json = self._serialize.body(gallery_images, "GalleryImagesUpdateRequest") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, gallery_image_name=gallery_image_name, subscription_id=self._config.subscription_id, @@ -727,41 +682,38 @@ def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("GalleryImages", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/galleryImages/{galleryImageName}" - } + return deserialized # type: ignore @overload def begin_update( @@ -785,14 +737,6 @@ def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either GalleryImages or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.GalleryImages] @@ -804,7 +748,7 @@ def begin_update( self, resource_group_name: str, gallery_image_name: str, - gallery_images: IO, + gallery_images: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -817,18 +761,10 @@ def begin_update( :param gallery_image_name: Name of the gallery image. Required. :type gallery_image_name: str :param gallery_images: Required. - :type gallery_images: IO + :type gallery_images: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either GalleryImages or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.GalleryImages] @@ -840,7 +776,7 @@ def begin_update( self, resource_group_name: str, gallery_image_name: str, - gallery_images: Union[_models.GalleryImagesUpdateRequest, IO], + gallery_images: Union[_models.GalleryImagesUpdateRequest, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.GalleryImages]: """The operation to update a gallery image. @@ -850,19 +786,9 @@ def begin_update( :type resource_group_name: str :param gallery_image_name: Name of the gallery image. Required. :type gallery_image_name: str - :param gallery_images: Is either a GalleryImagesUpdateRequest type or a IO type. Required. - :type gallery_images: ~azure.mgmt.azurestackhci.models.GalleryImagesUpdateRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param gallery_images: Is either a GalleryImagesUpdateRequest type or a IO[bytes] type. + Required. + :type gallery_images: ~azure.mgmt.azurestackhci.models.GalleryImagesUpdateRequest or IO[bytes] :return: An instance of LROPoller that returns either GalleryImages or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.GalleryImages] @@ -889,12 +815,13 @@ def begin_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("GalleryImages", pipeline_response) + deserialized = self._deserialize("GalleryImages", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -906,17 +833,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.GalleryImages].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/galleryImages/{galleryImageName}" - } + return LROPoller[_models.GalleryImages]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.GalleryImages"]: @@ -926,7 +851,6 @@ def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Gal :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either GalleryImages or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.GalleryImages] :raises ~azure.core.exceptions.HttpResponseError: @@ -937,7 +861,7 @@ def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Gal api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.GalleryImagesListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -948,16 +872,14 @@ def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Gal def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -969,13 +891,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("GalleryImagesListResult", pipeline_response) @@ -985,11 +906,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1002,16 +923,11 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/galleryImages" - } - @distributed_trace def list_all(self, **kwargs: Any) -> Iterable["_models.GalleryImages"]: """Lists all of the gallery images in the specified subscription. Use the nextLink property in the response to get the next page of gallery images. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either GalleryImages or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.GalleryImages] :raises ~azure.core.exceptions.HttpResponseError: @@ -1022,7 +938,7 @@ def list_all(self, **kwargs: Any) -> Iterable["_models.GalleryImages"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.GalleryImagesListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1033,15 +949,13 @@ def list_all(self, **kwargs: Any) -> Iterable["_models.GalleryImages"]: def prepare_request(next_link=None): if not next_link: - request = build_list_all_request( + _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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1053,13 +967,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("GalleryImagesListResult", pipeline_response) @@ -1069,11 +982,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1085,5 +998,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_all.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/galleryImages"} diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_guest_agent_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_guest_agent_operations.py index 42c32c4181b1..af7ed5fa02e8 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_guest_agent_operations.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_guest_agent_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterator, Optional, Type, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -15,12 +16,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -28,8 +30,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -41,7 +46,7 @@ def build_create_request(resource_uri: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -71,7 +76,7 @@ def build_get_request(resource_uri: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -98,7 +103,7 @@ def build_delete_request(resource_uri: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -141,9 +146,9 @@ def __init__(self, *args, **kwargs): self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") def _create_initial( - self, resource_uri: str, body: Optional[Union[_models.GuestAgent, IO]] = None, **kwargs: Any - ) -> _models.GuestAgent: - error_map = { + self, resource_uri: str, body: Optional[Union[_models.GuestAgent, IO[bytes]]] = None, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -156,7 +161,7 @@ def _create_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.GuestAgent] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -169,46 +174,41 @@ def _create_initial( else: _json = None - request = build_create_request( + _request = build_create_request( resource_uri=resource_uri, api_version=api_version, content_type=content_type, json=_json, content=_content, - 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("GuestAgent", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("GuestAgent", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_initial.metadata = { - "url": "/{resourceUri}/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default/guestAgents/default" - } - @overload def begin_create( self, @@ -230,14 +230,6 @@ def begin_create( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either GuestAgent or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.GuestAgent] :raises ~azure.core.exceptions.HttpResponseError: @@ -245,7 +237,12 @@ def begin_create( @overload def begin_create( - self, resource_uri: str, body: Optional[IO] = None, *, content_type: str = "application/json", **kwargs: Any + self, + resource_uri: str, + body: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any ) -> LROPoller[_models.GuestAgent]: """Implements GuestAgent PUT method. @@ -255,18 +252,10 @@ def begin_create( Compute machine resource to be extended. Required. :type resource_uri: str :param body: Request payload. Default value is None. - :type body: IO + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either GuestAgent or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.GuestAgent] :raises ~azure.core.exceptions.HttpResponseError: @@ -274,7 +263,7 @@ def begin_create( @distributed_trace def begin_create( - self, resource_uri: str, body: Optional[Union[_models.GuestAgent, IO]] = None, **kwargs: Any + self, resource_uri: str, body: Optional[Union[_models.GuestAgent, IO[bytes]]] = None, **kwargs: Any ) -> LROPoller[_models.GuestAgent]: """Implements GuestAgent PUT method. @@ -283,19 +272,9 @@ def begin_create( :param resource_uri: The fully qualified Azure Resource manager identifier of the Hybrid Compute machine resource to be extended. Required. :type resource_uri: str - :param body: Request payload. Is either a GuestAgent type or a IO type. Default value is None. - :type body: ~azure.mgmt.azurestackhci.models.GuestAgent or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param body: Request payload. Is either a GuestAgent type or a IO[bytes] type. Default value is + None. + :type body: ~azure.mgmt.azurestackhci.models.GuestAgent or IO[bytes] :return: An instance of LROPoller that returns either GuestAgent or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.GuestAgent] :raises ~azure.core.exceptions.HttpResponseError: @@ -320,12 +299,13 @@ def begin_create( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("GuestAgent", pipeline_response) + deserialized = self._deserialize("GuestAgent", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -337,17 +317,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.GuestAgent].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create.metadata = { - "url": "/{resourceUri}/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default/guestAgents/default" - } + return LROPoller[_models.GuestAgent]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def get(self, resource_uri: str, **kwargs: Any) -> _models.GuestAgent: @@ -358,12 +336,11 @@ def get(self, resource_uri: str, **kwargs: Any) -> _models.GuestAgent: :param resource_uri: The fully qualified Azure Resource manager identifier of the Hybrid Compute machine resource to be extended. Required. :type resource_uri: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: GuestAgent or the result of cls(response) :rtype: ~azure.mgmt.azurestackhci.models.GuestAgent :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -377,19 +354,17 @@ def get(self, resource_uri: str, **kwargs: Any) -> _models.GuestAgent: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.GuestAgent] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_uri=resource_uri, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -399,21 +374,15 @@ def get(self, resource_uri: str, **kwargs: Any) -> _models.GuestAgent: error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("GuestAgent", pipeline_response) + deserialized = self._deserialize("GuestAgent", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/{resourceUri}/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default/guestAgents/default" - } + return deserialized # type: ignore - def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_uri: str, **kwargs: Any - ) -> None: - error_map = { + def _delete_initial(self, resource_uri: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -425,26 +394,29 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_uri=resource_uri, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -453,12 +425,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/{resourceUri}/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default/guestAgents/default" - } + return deserialized # type: ignore @distributed_trace def begin_delete(self, resource_uri: str, **kwargs: Any) -> LROPoller[None]: @@ -469,14 +441,6 @@ def begin_delete(self, resource_uri: str, **kwargs: Any) -> LROPoller[None]: :param resource_uri: The fully qualified Azure Resource manager identifier of the Hybrid Compute machine resource to be extended. Required. :type resource_uri: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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: @@ -490,7 +454,7 @@ def begin_delete(self, resource_uri: str, **kwargs: Any) -> LROPoller[None]: lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_uri=resource_uri, api_version=api_version, cls=lambda x, y, z: x, @@ -498,11 +462,12 @@ def begin_delete(self, resource_uri: str, **kwargs: Any) -> LROPoller[None]: params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -511,14 +476,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/{resourceUri}/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default/guestAgents/default" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_guest_agents_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_guest_agents_operations.py index 6e344e89ac2f..618b7605705a 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_guest_agents_operations.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_guest_agents_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) 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.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +43,7 @@ def build_list_request(resource_uri: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -90,7 +93,6 @@ def list(self, resource_uri: str, **kwargs: Any) -> Iterable["_models.GuestAgent :param resource_uri: The fully qualified Azure Resource manager identifier of the Hybrid Compute machine resource to be extended. Required. :type resource_uri: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either GuestAgent or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.GuestAgent] :raises ~azure.core.exceptions.HttpResponseError: @@ -101,7 +103,7 @@ def list(self, resource_uri: str, **kwargs: Any) -> Iterable["_models.GuestAgent api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.GuestAgentList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -112,15 +114,13 @@ def list(self, resource_uri: str, **kwargs: Any) -> Iterable["_models.GuestAgent def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_uri=resource_uri, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -132,13 +132,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("GuestAgentList", pipeline_response) @@ -148,11 +147,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -164,7 +163,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/{resourceUri}/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default/guestAgents" - } diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_hybrid_identity_metadata_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_hybrid_identity_metadata_operations.py index 7dc46d1ca1e6..33dd118753f8 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_hybrid_identity_metadata_operations.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_hybrid_identity_metadata_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,7 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar import urllib.parse from azure.core.exceptions import ( @@ -19,16 +20,18 @@ ) 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.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +43,7 @@ def build_get_request(resource_uri: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -67,7 +70,7 @@ def build_list_request(resource_uri: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -118,12 +121,11 @@ def get(self, resource_uri: str, **kwargs: Any) -> _models.HybridIdentityMetadat :param resource_uri: The fully qualified Azure Resource manager identifier of the Hybrid Compute machine resource to be extended. Required. :type resource_uri: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: HybridIdentityMetadata or the result of cls(response) :rtype: ~azure.mgmt.azurestackhci.models.HybridIdentityMetadata :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -137,19 +139,17 @@ def get(self, resource_uri: str, **kwargs: Any) -> _models.HybridIdentityMetadat api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.HybridIdentityMetadata] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_uri=resource_uri, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -159,16 +159,12 @@ def get(self, resource_uri: str, **kwargs: Any) -> _models.HybridIdentityMetadat error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("HybridIdentityMetadata", pipeline_response) + deserialized = self._deserialize("HybridIdentityMetadata", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/{resourceUri}/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default/hybridIdentityMetadata/default" - } + return deserialized # type: ignore @distributed_trace def list(self, resource_uri: str, **kwargs: Any) -> Iterable["_models.HybridIdentityMetadata"]: @@ -179,7 +175,6 @@ def list(self, resource_uri: str, **kwargs: Any) -> Iterable["_models.HybridIden :param resource_uri: The fully qualified Azure Resource manager identifier of the Hybrid Compute machine resource to be extended. Required. :type resource_uri: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either HybridIdentityMetadata or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.HybridIdentityMetadata] @@ -191,7 +186,7 @@ def list(self, resource_uri: str, **kwargs: Any) -> Iterable["_models.HybridIden api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.HybridIdentityMetadataList] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -202,15 +197,13 @@ def list(self, resource_uri: str, **kwargs: Any) -> Iterable["_models.HybridIden def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_uri=resource_uri, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -222,13 +215,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("HybridIdentityMetadataList", pipeline_response) @@ -238,11 +230,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -254,7 +246,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/{resourceUri}/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default/hybridIdentityMetadata" - } diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_logical_networks_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_logical_networks_operations.py index 16a7ab1f1ae8..d4ed92dc3b84 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_logical_networks_operations.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_logical_networks_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, 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.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +50,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -85,7 +90,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -128,7 +133,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -168,7 +173,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -209,7 +214,7 @@ def build_list_request(resource_group_name: str, subscription_id: str, **kwargs: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -239,7 +244,7 @@ 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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -289,12 +294,11 @@ def get(self, resource_group_name: str, logical_network_name: str, **kwargs: Any :type resource_group_name: str :param logical_network_name: Name of the logical network. Required. :type logical_network_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: LogicalNetworks or the result of cls(response) :rtype: ~azure.mgmt.azurestackhci.models.LogicalNetworks :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -308,21 +312,19 @@ def get(self, resource_group_name: str, logical_network_name: str, **kwargs: Any api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.LogicalNetworks] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, logical_network_name=logical_network_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -332,25 +334,21 @@ def get(self, resource_group_name: str, logical_network_name: str, **kwargs: Any error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("LogicalNetworks", pipeline_response) + deserialized = self._deserialize("LogicalNetworks", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/logicalNetworks/{logicalNetworkName}" - } + return deserialized # type: ignore def _create_or_update_initial( self, resource_group_name: str, logical_network_name: str, - logical_networks: Union[_models.LogicalNetworks, IO], + logical_networks: Union[_models.LogicalNetworks, IO[bytes]], **kwargs: Any - ) -> _models.LogicalNetworks: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -363,7 +361,7 @@ def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.LogicalNetworks] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -373,7 +371,7 @@ def _create_or_update_initial( else: _json = self._serialize.body(logical_networks, "LogicalNetworks") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, logical_network_name=logical_network_name, subscription_id=self._config.subscription_id, @@ -381,40 +379,35 @@ def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("LogicalNetworks", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("LogicalNetworks", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/logicalNetworks/{logicalNetworkName}" - } - @overload def begin_create_or_update( self, @@ -438,14 +431,6 @@ def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either LogicalNetworks or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.LogicalNetworks] @@ -457,7 +442,7 @@ def begin_create_or_update( self, resource_group_name: str, logical_network_name: str, - logical_networks: IO, + logical_networks: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -471,18 +456,10 @@ def begin_create_or_update( :param logical_network_name: Name of the logical network. Required. :type logical_network_name: str :param logical_networks: Required. - :type logical_networks: IO + :type logical_networks: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either LogicalNetworks or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.LogicalNetworks] @@ -494,7 +471,7 @@ def begin_create_or_update( self, resource_group_name: str, logical_network_name: str, - logical_networks: Union[_models.LogicalNetworks, IO], + logical_networks: Union[_models.LogicalNetworks, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.LogicalNetworks]: """The operation to create or update a logical network. Please note some properties can be set @@ -505,19 +482,8 @@ def begin_create_or_update( :type resource_group_name: str :param logical_network_name: Name of the logical network. Required. :type logical_network_name: str - :param logical_networks: Is either a LogicalNetworks type or a IO type. Required. - :type logical_networks: ~azure.mgmt.azurestackhci.models.LogicalNetworks or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param logical_networks: Is either a LogicalNetworks type or a IO[bytes] type. Required. + :type logical_networks: ~azure.mgmt.azurestackhci.models.LogicalNetworks or IO[bytes] :return: An instance of LROPoller that returns either LogicalNetworks or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.LogicalNetworks] @@ -544,12 +510,13 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("LogicalNetworks", pipeline_response) + deserialized = self._deserialize("LogicalNetworks", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -561,22 +528,18 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.LogicalNetworks].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/logicalNetworks/{logicalNetworkName}" - } + return LROPoller[_models.LogicalNetworks]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, logical_network_name: str, **kwargs: Any - ) -> None: - error_map = { + def _delete_initial(self, resource_group_name: str, logical_network_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -588,28 +551,31 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, logical_network_name=logical_network_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) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -618,12 +584,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/logicalNetworks/{logicalNetworkName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete(self, resource_group_name: str, logical_network_name: str, **kwargs: Any) -> LROPoller[None]: @@ -634,14 +600,6 @@ def begin_delete(self, resource_group_name: str, logical_network_name: str, **kw :type resource_group_name: str :param logical_network_name: Name of the logical network. Required. :type logical_network_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: @@ -655,7 +613,7 @@ def begin_delete(self, resource_group_name: str, logical_network_name: str, **kw lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, logical_network_name=logical_network_name, api_version=api_version, @@ -664,11 +622,12 @@ def begin_delete(self, resource_group_name: str, logical_network_name: str, **kw params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -679,26 +638,22 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/logicalNetworks/{logicalNetworkName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _update_initial( self, resource_group_name: str, logical_network_name: str, - logical_networks: Union[_models.LogicalNetworksUpdateRequest, IO], + logical_networks: Union[_models.LogicalNetworksUpdateRequest, IO[bytes]], **kwargs: Any - ) -> Optional[_models.LogicalNetworks]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -711,7 +666,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.LogicalNetworks]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -721,7 +676,7 @@ def _update_initial( else: _json = self._serialize.body(logical_networks, "LogicalNetworksUpdateRequest") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, logical_network_name=logical_network_name, subscription_id=self._config.subscription_id, @@ -729,41 +684,38 @@ def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("LogicalNetworks", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/logicalNetworks/{logicalNetworkName}" - } + return deserialized # type: ignore @overload def begin_update( @@ -787,14 +739,6 @@ def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either LogicalNetworks or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.LogicalNetworks] @@ -806,7 +750,7 @@ def begin_update( self, resource_group_name: str, logical_network_name: str, - logical_networks: IO, + logical_networks: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -819,18 +763,10 @@ def begin_update( :param logical_network_name: Name of the logical network. Required. :type logical_network_name: str :param logical_networks: Required. - :type logical_networks: IO + :type logical_networks: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either LogicalNetworks or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.LogicalNetworks] @@ -842,7 +778,7 @@ def begin_update( self, resource_group_name: str, logical_network_name: str, - logical_networks: Union[_models.LogicalNetworksUpdateRequest, IO], + logical_networks: Union[_models.LogicalNetworksUpdateRequest, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.LogicalNetworks]: """The operation to update a logical network. @@ -852,19 +788,10 @@ def begin_update( :type resource_group_name: str :param logical_network_name: Name of the logical network. Required. :type logical_network_name: str - :param logical_networks: Is either a LogicalNetworksUpdateRequest type or a IO type. Required. - :type logical_networks: ~azure.mgmt.azurestackhci.models.LogicalNetworksUpdateRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param logical_networks: Is either a LogicalNetworksUpdateRequest type or a IO[bytes] type. + Required. + :type logical_networks: ~azure.mgmt.azurestackhci.models.LogicalNetworksUpdateRequest or + IO[bytes] :return: An instance of LROPoller that returns either LogicalNetworks or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.LogicalNetworks] @@ -891,12 +818,13 @@ def begin_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("LogicalNetworks", pipeline_response) + deserialized = self._deserialize("LogicalNetworks", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -908,17 +836,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.LogicalNetworks].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/logicalNetworks/{logicalNetworkName}" - } + return LROPoller[_models.LogicalNetworks]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.LogicalNetworks"]: @@ -928,7 +854,6 @@ def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Log :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either LogicalNetworks or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.LogicalNetworks] :raises ~azure.core.exceptions.HttpResponseError: @@ -939,7 +864,7 @@ def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Log api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.LogicalNetworksListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -950,16 +875,14 @@ def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Log def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -971,13 +894,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("LogicalNetworksListResult", pipeline_response) @@ -987,11 +909,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1004,16 +926,11 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/logicalNetworks" - } - @distributed_trace def list_all(self, **kwargs: Any) -> Iterable["_models.LogicalNetworks"]: """Lists all of the logical networks in the specified subscription. Use the nextLink property in the response to get the next page of logical networks. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either LogicalNetworks or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.LogicalNetworks] :raises ~azure.core.exceptions.HttpResponseError: @@ -1024,7 +941,7 @@ def list_all(self, **kwargs: Any) -> Iterable["_models.LogicalNetworks"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.LogicalNetworksListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1035,15 +952,13 @@ def list_all(self, **kwargs: Any) -> Iterable["_models.LogicalNetworks"]: def prepare_request(next_link=None): if not next_link: - request = build_list_all_request( + _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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1055,13 +970,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("LogicalNetworksListResult", pipeline_response) @@ -1071,11 +985,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1087,5 +1001,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_all.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/logicalNetworks"} diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_marketplace_gallery_images_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_marketplace_gallery_images_operations.py index 229c800bebe0..823d7364bfb5 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_marketplace_gallery_images_operations.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_marketplace_gallery_images_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, 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.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +50,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -85,7 +90,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -128,7 +133,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -168,7 +173,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -209,7 +214,7 @@ def build_list_request(resource_group_name: str, subscription_id: str, **kwargs: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -239,7 +244,7 @@ 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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -291,12 +296,11 @@ def get( :type resource_group_name: str :param marketplace_gallery_image_name: Name of the marketplace gallery image. Required. :type marketplace_gallery_image_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: MarketplaceGalleryImages or the result of cls(response) :rtype: ~azure.mgmt.azurestackhci.models.MarketplaceGalleryImages :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -310,21 +314,19 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.MarketplaceGalleryImages] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, marketplace_gallery_image_name=marketplace_gallery_image_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -334,25 +336,21 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("MarketplaceGalleryImages", pipeline_response) + deserialized = self._deserialize("MarketplaceGalleryImages", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/marketplaceGalleryImages/{marketplaceGalleryImageName}" - } + return deserialized # type: ignore def _create_or_update_initial( self, resource_group_name: str, marketplace_gallery_image_name: str, - marketplace_gallery_images: Union[_models.MarketplaceGalleryImages, IO], + marketplace_gallery_images: Union[_models.MarketplaceGalleryImages, IO[bytes]], **kwargs: Any - ) -> _models.MarketplaceGalleryImages: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -365,7 +363,7 @@ def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.MarketplaceGalleryImages] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -375,7 +373,7 @@ def _create_or_update_initial( else: _json = self._serialize.body(marketplace_gallery_images, "MarketplaceGalleryImages") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, marketplace_gallery_image_name=marketplace_gallery_image_name, subscription_id=self._config.subscription_id, @@ -383,40 +381,35 @@ def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("MarketplaceGalleryImages", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("MarketplaceGalleryImages", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/marketplaceGalleryImages/{marketplaceGalleryImageName}" - } - @overload def begin_create_or_update( self, @@ -440,14 +433,6 @@ def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either MarketplaceGalleryImages or the result of cls(response) :rtype: @@ -460,7 +445,7 @@ def begin_create_or_update( self, resource_group_name: str, marketplace_gallery_image_name: str, - marketplace_gallery_images: IO, + marketplace_gallery_images: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -474,18 +459,10 @@ def begin_create_or_update( :param marketplace_gallery_image_name: Name of the marketplace gallery image. Required. :type marketplace_gallery_image_name: str :param marketplace_gallery_images: Required. - :type marketplace_gallery_images: IO + :type marketplace_gallery_images: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either MarketplaceGalleryImages or the result of cls(response) :rtype: @@ -498,7 +475,7 @@ def begin_create_or_update( self, resource_group_name: str, marketplace_gallery_image_name: str, - marketplace_gallery_images: Union[_models.MarketplaceGalleryImages, IO], + marketplace_gallery_images: Union[_models.MarketplaceGalleryImages, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.MarketplaceGalleryImages]: """The operation to create or update a marketplace gallery image. Please note some properties can @@ -509,21 +486,10 @@ def begin_create_or_update( :type resource_group_name: str :param marketplace_gallery_image_name: Name of the marketplace gallery image. Required. :type marketplace_gallery_image_name: str - :param marketplace_gallery_images: Is either a MarketplaceGalleryImages type or a IO type. - Required. + :param marketplace_gallery_images: Is either a MarketplaceGalleryImages type or a IO[bytes] + type. Required. :type marketplace_gallery_images: ~azure.mgmt.azurestackhci.models.MarketplaceGalleryImages or - IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + IO[bytes] :return: An instance of LROPoller that returns either MarketplaceGalleryImages or the result of cls(response) :rtype: @@ -551,12 +517,13 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("MarketplaceGalleryImages", pipeline_response) + deserialized = self._deserialize("MarketplaceGalleryImages", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -568,22 +535,20 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.MarketplaceGalleryImages].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/marketplaceGalleryImages/{marketplaceGalleryImageName}" - } + return LROPoller[_models.MarketplaceGalleryImages]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _delete_initial( # pylint: disable=inconsistent-return-statements + def _delete_initial( self, resource_group_name: str, marketplace_gallery_image_name: str, **kwargs: Any - ) -> None: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -595,28 +560,31 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, marketplace_gallery_image_name=marketplace_gallery_image_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) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -625,12 +593,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/marketplaceGalleryImages/{marketplaceGalleryImageName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -643,14 +611,6 @@ def begin_delete( :type resource_group_name: str :param marketplace_gallery_image_name: Name of the marketplace gallery image. Required. :type marketplace_gallery_image_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: @@ -664,7 +624,7 @@ def begin_delete( lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, marketplace_gallery_image_name=marketplace_gallery_image_name, api_version=api_version, @@ -673,11 +633,12 @@ def begin_delete( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -688,26 +649,22 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/marketplaceGalleryImages/{marketplaceGalleryImageName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _update_initial( self, resource_group_name: str, marketplace_gallery_image_name: str, - marketplace_gallery_images: Union[_models.MarketplaceGalleryImagesUpdateRequest, IO], + marketplace_gallery_images: Union[_models.MarketplaceGalleryImagesUpdateRequest, IO[bytes]], **kwargs: Any - ) -> Optional[_models.MarketplaceGalleryImages]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -720,7 +677,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.MarketplaceGalleryImages]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -730,7 +687,7 @@ def _update_initial( else: _json = self._serialize.body(marketplace_gallery_images, "MarketplaceGalleryImagesUpdateRequest") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, marketplace_gallery_image_name=marketplace_gallery_image_name, subscription_id=self._config.subscription_id, @@ -738,41 +695,38 @@ def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("MarketplaceGalleryImages", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/marketplaceGalleryImages/{marketplaceGalleryImageName}" - } + return deserialized # type: ignore @overload def begin_update( @@ -797,14 +751,6 @@ def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either MarketplaceGalleryImages or the result of cls(response) :rtype: @@ -817,7 +763,7 @@ def begin_update( self, resource_group_name: str, marketplace_gallery_image_name: str, - marketplace_gallery_images: IO, + marketplace_gallery_images: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -830,18 +776,10 @@ def begin_update( :param marketplace_gallery_image_name: Name of the marketplace gallery image. Required. :type marketplace_gallery_image_name: str :param marketplace_gallery_images: Required. - :type marketplace_gallery_images: IO + :type marketplace_gallery_images: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either MarketplaceGalleryImages or the result of cls(response) :rtype: @@ -854,7 +792,7 @@ def begin_update( self, resource_group_name: str, marketplace_gallery_image_name: str, - marketplace_gallery_images: Union[_models.MarketplaceGalleryImagesUpdateRequest, IO], + marketplace_gallery_images: Union[_models.MarketplaceGalleryImagesUpdateRequest, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.MarketplaceGalleryImages]: """The operation to update a marketplace gallery image. @@ -865,20 +803,9 @@ def begin_update( :param marketplace_gallery_image_name: Name of the marketplace gallery image. Required. :type marketplace_gallery_image_name: str :param marketplace_gallery_images: Is either a MarketplaceGalleryImagesUpdateRequest type or a - IO type. Required. + IO[bytes] type. Required. :type marketplace_gallery_images: - ~azure.mgmt.azurestackhci.models.MarketplaceGalleryImagesUpdateRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + ~azure.mgmt.azurestackhci.models.MarketplaceGalleryImagesUpdateRequest or IO[bytes] :return: An instance of LROPoller that returns either MarketplaceGalleryImages or the result of cls(response) :rtype: @@ -906,12 +833,13 @@ def begin_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("MarketplaceGalleryImages", pipeline_response) + deserialized = self._deserialize("MarketplaceGalleryImages", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -923,17 +851,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.MarketplaceGalleryImages].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/marketplaceGalleryImages/{marketplaceGalleryImageName}" - } + return LROPoller[_models.MarketplaceGalleryImages]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.MarketplaceGalleryImages"]: @@ -943,7 +869,6 @@ def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Mar :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either MarketplaceGalleryImages or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.MarketplaceGalleryImages] @@ -955,7 +880,7 @@ def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Mar api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.MarketplaceGalleryImagesListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -966,16 +891,14 @@ def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Mar def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -987,13 +910,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("MarketplaceGalleryImagesListResult", pipeline_response) @@ -1003,11 +925,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1020,16 +942,11 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/marketplaceGalleryImages" - } - @distributed_trace def list_all(self, **kwargs: Any) -> Iterable["_models.MarketplaceGalleryImages"]: """Lists all of the marketplace gallery images in the specified subscription. Use the nextLink property in the response to get the next page of marketplace gallery images. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either MarketplaceGalleryImages or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.MarketplaceGalleryImages] @@ -1041,7 +958,7 @@ def list_all(self, **kwargs: Any) -> Iterable["_models.MarketplaceGalleryImages" api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.MarketplaceGalleryImagesListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1052,15 +969,13 @@ def list_all(self, **kwargs: Any) -> Iterable["_models.MarketplaceGalleryImages" def prepare_request(next_link=None): if not next_link: - request = build_list_all_request( + _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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1072,13 +987,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("MarketplaceGalleryImagesListResult", pipeline_response) @@ -1088,11 +1002,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1104,7 +1018,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_all.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/marketplaceGalleryImages" - } diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_network_interfaces_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_network_interfaces_operations.py index 22f130f8b46f..b08530795772 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_network_interfaces_operations.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_network_interfaces_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, 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.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +50,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -85,7 +90,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -128,7 +133,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -168,7 +173,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -209,7 +214,7 @@ def build_list_request(resource_group_name: str, subscription_id: str, **kwargs: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -239,7 +244,7 @@ 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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -289,12 +294,11 @@ def get(self, resource_group_name: str, network_interface_name: str, **kwargs: A :type resource_group_name: str :param network_interface_name: Name of the network interface. Required. :type network_interface_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: NetworkInterfaces or the result of cls(response) :rtype: ~azure.mgmt.azurestackhci.models.NetworkInterfaces :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -308,21 +312,19 @@ def get(self, resource_group_name: str, network_interface_name: str, **kwargs: A api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.NetworkInterfaces] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, network_interface_name=network_interface_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -332,25 +334,21 @@ def get(self, resource_group_name: str, network_interface_name: str, **kwargs: A error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("NetworkInterfaces", pipeline_response) + deserialized = self._deserialize("NetworkInterfaces", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/networkInterfaces/{networkInterfaceName}" - } + return deserialized # type: ignore def _create_or_update_initial( self, resource_group_name: str, network_interface_name: str, - network_interfaces: Union[_models.NetworkInterfaces, IO], + network_interfaces: Union[_models.NetworkInterfaces, IO[bytes]], **kwargs: Any - ) -> _models.NetworkInterfaces: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -363,7 +361,7 @@ def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.NetworkInterfaces] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -373,7 +371,7 @@ def _create_or_update_initial( else: _json = self._serialize.body(network_interfaces, "NetworkInterfaces") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, network_interface_name=network_interface_name, subscription_id=self._config.subscription_id, @@ -381,40 +379,35 @@ def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("NetworkInterfaces", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("NetworkInterfaces", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/networkInterfaces/{networkInterfaceName}" - } - @overload def begin_create_or_update( self, @@ -438,14 +431,6 @@ def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either NetworkInterfaces or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.NetworkInterfaces] @@ -457,7 +442,7 @@ def begin_create_or_update( self, resource_group_name: str, network_interface_name: str, - network_interfaces: IO, + network_interfaces: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -471,18 +456,10 @@ def begin_create_or_update( :param network_interface_name: Name of the network interface. Required. :type network_interface_name: str :param network_interfaces: Required. - :type network_interfaces: IO + :type network_interfaces: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either NetworkInterfaces or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.NetworkInterfaces] @@ -494,7 +471,7 @@ def begin_create_or_update( self, resource_group_name: str, network_interface_name: str, - network_interfaces: Union[_models.NetworkInterfaces, IO], + network_interfaces: Union[_models.NetworkInterfaces, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.NetworkInterfaces]: """The operation to create or update a network interface. Please note some properties can be set @@ -505,19 +482,8 @@ def begin_create_or_update( :type resource_group_name: str :param network_interface_name: Name of the network interface. Required. :type network_interface_name: str - :param network_interfaces: Is either a NetworkInterfaces type or a IO type. Required. - :type network_interfaces: ~azure.mgmt.azurestackhci.models.NetworkInterfaces or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param network_interfaces: Is either a NetworkInterfaces type or a IO[bytes] type. Required. + :type network_interfaces: ~azure.mgmt.azurestackhci.models.NetworkInterfaces or IO[bytes] :return: An instance of LROPoller that returns either NetworkInterfaces or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.NetworkInterfaces] @@ -544,12 +510,13 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("NetworkInterfaces", pipeline_response) + deserialized = self._deserialize("NetworkInterfaces", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -561,22 +528,18 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.NetworkInterfaces].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/networkInterfaces/{networkInterfaceName}" - } + return LROPoller[_models.NetworkInterfaces]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, network_interface_name: str, **kwargs: Any - ) -> None: - error_map = { + def _delete_initial(self, resource_group_name: str, network_interface_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -588,28 +551,31 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, network_interface_name=network_interface_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) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -618,12 +584,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/networkInterfaces/{networkInterfaceName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete(self, resource_group_name: str, network_interface_name: str, **kwargs: Any) -> LROPoller[None]: @@ -634,14 +600,6 @@ def begin_delete(self, resource_group_name: str, network_interface_name: str, ** :type resource_group_name: str :param network_interface_name: Name of the network interface. Required. :type network_interface_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: @@ -655,7 +613,7 @@ def begin_delete(self, resource_group_name: str, network_interface_name: str, ** lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, network_interface_name=network_interface_name, api_version=api_version, @@ -664,11 +622,12 @@ def begin_delete(self, resource_group_name: str, network_interface_name: str, ** params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -679,26 +638,22 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/networkInterfaces/{networkInterfaceName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _update_initial( self, resource_group_name: str, network_interface_name: str, - network_interfaces: Union[_models.NetworkInterfacesUpdateRequest, IO], + network_interfaces: Union[_models.NetworkInterfacesUpdateRequest, IO[bytes]], **kwargs: Any - ) -> Optional[_models.NetworkInterfaces]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -711,7 +666,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.NetworkInterfaces]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -721,7 +676,7 @@ def _update_initial( else: _json = self._serialize.body(network_interfaces, "NetworkInterfacesUpdateRequest") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, network_interface_name=network_interface_name, subscription_id=self._config.subscription_id, @@ -729,41 +684,38 @@ def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("NetworkInterfaces", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/networkInterfaces/{networkInterfaceName}" - } + return deserialized # type: ignore @overload def begin_update( @@ -787,14 +739,6 @@ def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either NetworkInterfaces or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.NetworkInterfaces] @@ -806,7 +750,7 @@ def begin_update( self, resource_group_name: str, network_interface_name: str, - network_interfaces: IO, + network_interfaces: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -819,18 +763,10 @@ def begin_update( :param network_interface_name: Name of the network interface. Required. :type network_interface_name: str :param network_interfaces: Required. - :type network_interfaces: IO + :type network_interfaces: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either NetworkInterfaces or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.NetworkInterfaces] @@ -842,7 +778,7 @@ def begin_update( self, resource_group_name: str, network_interface_name: str, - network_interfaces: Union[_models.NetworkInterfacesUpdateRequest, IO], + network_interfaces: Union[_models.NetworkInterfacesUpdateRequest, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.NetworkInterfaces]: """The operation to update a network interface. @@ -852,20 +788,10 @@ def begin_update( :type resource_group_name: str :param network_interface_name: Name of the network interface. Required. :type network_interface_name: str - :param network_interfaces: Is either a NetworkInterfacesUpdateRequest type or a IO type. + :param network_interfaces: Is either a NetworkInterfacesUpdateRequest type or a IO[bytes] type. Required. - :type network_interfaces: ~azure.mgmt.azurestackhci.models.NetworkInterfacesUpdateRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :type network_interfaces: ~azure.mgmt.azurestackhci.models.NetworkInterfacesUpdateRequest or + IO[bytes] :return: An instance of LROPoller that returns either NetworkInterfaces or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.NetworkInterfaces] @@ -892,12 +818,13 @@ def begin_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("NetworkInterfaces", pipeline_response) + deserialized = self._deserialize("NetworkInterfaces", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -909,17 +836,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.NetworkInterfaces].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/networkInterfaces/{networkInterfaceName}" - } + return LROPoller[_models.NetworkInterfaces]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.NetworkInterfaces"]: @@ -929,7 +854,6 @@ def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Net :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either NetworkInterfaces or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.NetworkInterfaces] :raises ~azure.core.exceptions.HttpResponseError: @@ -940,7 +864,7 @@ def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Net api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.NetworkInterfacesListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -951,16 +875,14 @@ def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Net def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -972,13 +894,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("NetworkInterfacesListResult", pipeline_response) @@ -988,11 +909,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1005,16 +926,11 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/networkInterfaces" - } - @distributed_trace def list_all(self, **kwargs: Any) -> Iterable["_models.NetworkInterfaces"]: """Lists all of the network interfaces in the specified subscription. Use the nextLink property in the response to get the next page of network interfaces. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either NetworkInterfaces or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.NetworkInterfaces] :raises ~azure.core.exceptions.HttpResponseError: @@ -1025,7 +941,7 @@ def list_all(self, **kwargs: Any) -> Iterable["_models.NetworkInterfaces"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.NetworkInterfacesListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1036,15 +952,13 @@ def list_all(self, **kwargs: Any) -> Iterable["_models.NetworkInterfaces"]: def prepare_request(next_link=None): if not next_link: - request = build_list_all_request( + _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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1056,13 +970,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("NetworkInterfacesListResult", pipeline_response) @@ -1072,11 +985,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1088,5 +1001,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_all.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/networkInterfaces"} diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_offers_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_offers_operations.py new file mode 100644 index 000000000000..09d23a1b47d1 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_offers_operations.py @@ -0,0 +1,438 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_publisher_request( + resource_group_name: str, + cluster_name: str, + publisher_name: str, + subscription_id: str, + *, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/publishers/{publisherName}/offers", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "publisherName": _SERIALIZER.url("publisher_name", publisher_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # 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_list_by_cluster_request( + resource_group_name: str, cluster_name: str, subscription_id: str, *, expand: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/offers", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # 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_request( + resource_group_name: str, + cluster_name: str, + publisher_name: str, + offer_name: str, + subscription_id: str, + *, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/publishers/{publisherName}/offers/{offerName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "publisherName": _SERIALIZER.url("publisher_name", publisher_name, "str"), + "offerName": _SERIALIZER.url("offer_name", offer_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # 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) + + +class OffersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.azurestackhci.AzureStackHCIClient`'s + :attr:`offers` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_publisher( + self, + resource_group_name: str, + cluster_name: str, + publisher_name: str, + expand: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.Offer"]: + """List Offers available for a publisher within the HCI Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param publisher_name: The name of the publisher available within HCI cluster. Required. + :type publisher_name: str + :param expand: Specify $expand=content,contentVersion to populate additional fields related to + the marketplace offer. Default value is None. + :type expand: str + :return: An iterator like instance of either Offer or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.Offer] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.OfferList] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_publisher_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + publisher_name=publisher_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("OfferList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_by_cluster( + self, resource_group_name: str, cluster_name: str, expand: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.Offer"]: + """List Offers available across publishers for the HCI Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param expand: Specify $expand=content,contentVersion to populate additional fields related to + the marketplace offer. Default value is None. + :type expand: str + :return: An iterator like instance of either Offer or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.Offer] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.OfferList] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_cluster_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("OfferList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, + resource_group_name: str, + cluster_name: str, + publisher_name: str, + offer_name: str, + expand: Optional[str] = None, + **kwargs: Any + ) -> _models.Offer: + """Get Offer resource details within a publisher of HCI Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param publisher_name: The name of the publisher available within HCI cluster. Required. + :type publisher_name: str + :param offer_name: The name of the offer available within HCI cluster. Required. + :type offer_name: str + :param expand: Specify $expand=content,contentVersion to populate additional fields related to + the marketplace offer. Default value is None. + :type expand: str + :return: Offer or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.Offer + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.Offer] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + publisher_name=publisher_name, + offer_name=offer_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Offer", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_operations.py index 5fcadb579bc1..9ddb3062d073 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_operations.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,8 +6,8 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -import urllib.parse +import sys +from typing import Any, Callable, Dict, Optional, Type, TypeVar from azure.core.exceptions import ( ClientAuthenticationError, @@ -17,18 +17,19 @@ ResourceNotModifiedError, map_error, ) -from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +41,7 @@ def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -75,21 +76,14 @@ def __init__(self, *args, **kwargs): self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: - """List all the supported operations. + def list(self, **kwargs: Any) -> _models.OperationListResult: + """List all available Microsoft.AzureStackHCI provider operations. - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either Operation or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.Operation] + :return: OperationListResult or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.OperationListResult :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -97,59 +91,34 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: } 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) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("OperationListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.AzureStackHCI/operations"} + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) + + _request = build_list_request( + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("OperationListResult", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_publishers_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_publishers_operations.py new file mode 100644 index 000000000000..5913e5eca090 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_publishers_operations.py @@ -0,0 +1,269 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_cluster_request( + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/publishers", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, cluster_name: str, publisher_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/publishers/{publisherName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "publisherName": _SERIALIZER.url("publisher_name", publisher_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class PublishersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.azurestackhci.AzureStackHCIClient`'s + :attr:`publishers` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_cluster( + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> Iterable["_models.Publisher"]: + """List Publishers available for the HCI Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :return: An iterator like instance of either Publisher or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.Publisher] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PublisherList] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_cluster_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("PublisherList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get(self, resource_group_name: str, cluster_name: str, publisher_name: str, **kwargs: Any) -> _models.Publisher: + """Get Publisher resource details of HCI Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param publisher_name: The name of the publisher available within HCI cluster. Required. + :type publisher_name: str + :return: Publisher or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.Publisher + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.Publisher] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + publisher_name=publisher_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Publisher", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_security_settings_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_security_settings_operations.py new file mode 100644 index 000000000000..51e18e09f972 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_security_settings_operations.py @@ -0,0 +1,693 @@ +# pylint: disable=too-many-lines,too-many-statements +# 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 io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_clusters_request( + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/securitySettings", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, + cluster_name: str, + subscription_id: str, + security_settings_name: str = "default", + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/securitySettings/{securitySettingsName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "securitySettingsName": _SERIALIZER.url( + "security_settings_name", security_settings_name, "str", pattern=r"^[a-zA-Z0-9-]{3,24}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + cluster_name: str, + subscription_id: str, + security_settings_name: str = "default", + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/securitySettings/{securitySettingsName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "securitySettingsName": _SERIALIZER.url( + "security_settings_name", security_settings_name, "str", pattern=r"^[a-zA-Z0-9-]{3,24}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + cluster_name: str, + subscription_id: str, + security_settings_name: str = "default", + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/securitySettings/{securitySettingsName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "securitySettingsName": _SERIALIZER.url( + "security_settings_name", security_settings_name, "str", pattern=r"^[a-zA-Z0-9-]{3,24}$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class SecuritySettingsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.azurestackhci.AzureStackHCIClient`'s + :attr:`security_settings` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_clusters( + self, resource_group_name: str, cluster_name: str, **kwargs: Any + ) -> Iterable["_models.SecuritySetting"]: + """List SecuritySetting resources by Clusters. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :return: An iterator like instance of either SecuritySetting or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.SecuritySetting] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SecuritySettingListResult] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_clusters_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SecuritySettingListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, resource_group_name: str, cluster_name: str, security_settings_name: str = "default", **kwargs: Any + ) -> _models.SecuritySetting: + """Get a SecuritySetting. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param security_settings_name: Name of security setting. Default value is "default". + :type security_settings_name: str + :return: SecuritySetting or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.SecuritySetting + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SecuritySetting] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + security_settings_name=security_settings_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SecuritySetting", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + cluster_name: str, + resource: Union[_models.SecuritySetting, IO[bytes]], + security_settings_name: str = "default", + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(resource, (IOBase, bytes)): + _content = resource + else: + _json = self._serialize.body(resource, "SecuritySetting") + + _request = build_create_or_update_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + security_settings_name=security_settings_name, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 201: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + cluster_name: str, + resource: _models.SecuritySetting, + security_settings_name: str = "default", + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SecuritySetting]: + """Create a security setting. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param resource: Resource create parameters. Required. + :type resource: ~azure.mgmt.azurestackhci.models.SecuritySetting + :param security_settings_name: Name of security setting. Default value is "default". + :type security_settings_name: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either SecuritySetting or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.SecuritySetting] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + cluster_name: str, + resource: IO[bytes], + security_settings_name: str = "default", + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SecuritySetting]: + """Create a security setting. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param resource: Resource create parameters. Required. + :type resource: IO[bytes] + :param security_settings_name: Name of security setting. Default value is "default". + :type security_settings_name: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either SecuritySetting or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.SecuritySetting] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + cluster_name: str, + resource: Union[_models.SecuritySetting, IO[bytes]], + security_settings_name: str = "default", + **kwargs: Any + ) -> LROPoller[_models.SecuritySetting]: + """Create a security setting. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param resource: Resource create parameters. Is either a SecuritySetting type or a IO[bytes] + type. Required. + :type resource: ~azure.mgmt.azurestackhci.models.SecuritySetting or IO[bytes] + :param security_settings_name: Name of security setting. Default value is "default". + :type security_settings_name: str + :return: An instance of LROPoller that returns either SecuritySetting or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.SecuritySetting] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SecuritySetting] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + resource=resource, + security_settings_name=security_settings_name, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("SecuritySetting", pipeline_response.http_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.SecuritySetting].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.SecuritySetting]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _delete_initial( + self, resource_group_name: str, cluster_name: str, security_settings_name: str = "default", **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + security_settings_name=security_settings_name, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, cluster_name: str, security_settings_name: str = "default", **kwargs: Any + ) -> LROPoller[None]: + """Delete a SecuritySetting. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param security_settings_name: Name of security setting. Default value is "default". + :type security_settings_name: str + :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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + security_settings_name=security_settings_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_skus_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_skus_operations.py new file mode 100644 index 000000000000..b721abb12dc4 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_skus_operations.py @@ -0,0 +1,327 @@ +# pylint: disable=too-many-lines,too-many-statements +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_offer_request( + resource_group_name: str, + cluster_name: str, + publisher_name: str, + offer_name: str, + subscription_id: str, + *, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/publishers/{publisherName}/offers/{offerName}/skus", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "publisherName": _SERIALIZER.url("publisher_name", publisher_name, "str"), + "offerName": _SERIALIZER.url("offer_name", offer_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # 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_request( + resource_group_name: str, + cluster_name: str, + publisher_name: str, + offer_name: str, + sku_name: str, + subscription_id: str, + *, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/publishers/{publisherName}/offers/{offerName}/skus/{skuName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "publisherName": _SERIALIZER.url("publisher_name", publisher_name, "str"), + "offerName": _SERIALIZER.url("offer_name", offer_name, "str"), + "skuName": _SERIALIZER.url("sku_name", sku_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # 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) + + +class SkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.azurestackhci.AzureStackHCIClient`'s + :attr:`skus` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_offer( + self, + resource_group_name: str, + cluster_name: str, + publisher_name: str, + offer_name: str, + expand: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.Sku"]: + """List Skus available for a offer within the HCI Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param publisher_name: The name of the publisher available within HCI cluster. Required. + :type publisher_name: str + :param offer_name: The name of the offer available within HCI cluster. Required. + :type offer_name: str + :param expand: Specify $expand=content,contentVersion to populate additional fields related to + the marketplace offer. Default value is None. + :type expand: str + :return: An iterator like instance of either Sku or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.Sku] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SkuList] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_by_offer_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + publisher_name=publisher_name, + offer_name=offer_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SkuList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get( + self, + resource_group_name: str, + cluster_name: str, + publisher_name: str, + offer_name: str, + sku_name: str, + expand: Optional[str] = None, + **kwargs: Any + ) -> _models.Sku: + """Get SKU resource details within a offer of HCI Cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param publisher_name: The name of the publisher available within HCI cluster. Required. + :type publisher_name: str + :param offer_name: The name of the offer available within HCI cluster. Required. + :type offer_name: str + :param sku_name: The name of the SKU available within HCI cluster. Required. + :type sku_name: str + :param expand: Specify $expand=content,contentVersion to populate additional fields related to + the marketplace offer. Default value is None. + :type expand: str + :return: Sku or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.Sku + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.Sku] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + publisher_name=publisher_name, + offer_name=offer_name, + sku_name=sku_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Sku", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_storage_containers_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_storage_containers_operations.py index 75a552720d1b..a704c6db8744 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_storage_containers_operations.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_storage_containers_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, 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.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +50,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -85,7 +90,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -128,7 +133,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -168,7 +173,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -209,7 +214,7 @@ def build_list_request(resource_group_name: str, subscription_id: str, **kwargs: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -239,7 +244,7 @@ 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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -289,12 +294,11 @@ def get(self, resource_group_name: str, storage_container_name: str, **kwargs: A :type resource_group_name: str :param storage_container_name: Name of the storage container. Required. :type storage_container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageContainers or the result of cls(response) :rtype: ~azure.mgmt.azurestackhci.models.StorageContainers :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -308,21 +312,19 @@ def get(self, resource_group_name: str, storage_container_name: str, **kwargs: A api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.StorageContainers] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, storage_container_name=storage_container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -332,25 +334,21 @@ def get(self, resource_group_name: str, storage_container_name: str, **kwargs: A error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("StorageContainers", pipeline_response) + deserialized = self._deserialize("StorageContainers", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/storageContainers/{storageContainerName}" - } + return deserialized # type: ignore def _create_or_update_initial( self, resource_group_name: str, storage_container_name: str, - storage_containers: Union[_models.StorageContainers, IO], + storage_containers: Union[_models.StorageContainers, IO[bytes]], **kwargs: Any - ) -> _models.StorageContainers: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -363,7 +361,7 @@ def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.StorageContainers] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -373,7 +371,7 @@ def _create_or_update_initial( else: _json = self._serialize.body(storage_containers, "StorageContainers") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, storage_container_name=storage_container_name, subscription_id=self._config.subscription_id, @@ -381,40 +379,35 @@ def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("StorageContainers", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("StorageContainers", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/storageContainers/{storageContainerName}" - } - @overload def begin_create_or_update( self, @@ -438,14 +431,6 @@ def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either StorageContainers or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.StorageContainers] @@ -457,7 +442,7 @@ def begin_create_or_update( self, resource_group_name: str, storage_container_name: str, - storage_containers: IO, + storage_containers: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -471,18 +456,10 @@ def begin_create_or_update( :param storage_container_name: Name of the storage container. Required. :type storage_container_name: str :param storage_containers: Required. - :type storage_containers: IO + :type storage_containers: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either StorageContainers or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.StorageContainers] @@ -494,7 +471,7 @@ def begin_create_or_update( self, resource_group_name: str, storage_container_name: str, - storage_containers: Union[_models.StorageContainers, IO], + storage_containers: Union[_models.StorageContainers, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.StorageContainers]: """The operation to create or update a storage container. Please note some properties can be set @@ -505,19 +482,8 @@ def begin_create_or_update( :type resource_group_name: str :param storage_container_name: Name of the storage container. Required. :type storage_container_name: str - :param storage_containers: Is either a StorageContainers type or a IO type. Required. - :type storage_containers: ~azure.mgmt.azurestackhci.models.StorageContainers or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param storage_containers: Is either a StorageContainers type or a IO[bytes] type. Required. + :type storage_containers: ~azure.mgmt.azurestackhci.models.StorageContainers or IO[bytes] :return: An instance of LROPoller that returns either StorageContainers or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.StorageContainers] @@ -544,12 +510,13 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("StorageContainers", pipeline_response) + deserialized = self._deserialize("StorageContainers", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -561,22 +528,18 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.StorageContainers].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/storageContainers/{storageContainerName}" - } + return LROPoller[_models.StorageContainers]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, storage_container_name: str, **kwargs: Any - ) -> None: - error_map = { + def _delete_initial(self, resource_group_name: str, storage_container_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -588,28 +551,31 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, storage_container_name=storage_container_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) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -618,12 +584,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/storageContainers/{storageContainerName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete(self, resource_group_name: str, storage_container_name: str, **kwargs: Any) -> LROPoller[None]: @@ -634,14 +600,6 @@ def begin_delete(self, resource_group_name: str, storage_container_name: str, ** :type resource_group_name: str :param storage_container_name: Name of the storage container. Required. :type storage_container_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -655,7 +613,7 @@ def begin_delete(self, resource_group_name: str, storage_container_name: str, ** lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, storage_container_name=storage_container_name, api_version=api_version, @@ -664,11 +622,12 @@ def begin_delete(self, resource_group_name: str, storage_container_name: str, ** params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -679,26 +638,22 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/storageContainers/{storageContainerName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _update_initial( self, resource_group_name: str, storage_container_name: str, - storage_containers: Union[_models.StorageContainersUpdateRequest, IO], + storage_containers: Union[_models.StorageContainersUpdateRequest, IO[bytes]], **kwargs: Any - ) -> Optional[_models.StorageContainers]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -711,7 +666,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.StorageContainers]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -721,7 +676,7 @@ def _update_initial( else: _json = self._serialize.body(storage_containers, "StorageContainersUpdateRequest") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, storage_container_name=storage_container_name, subscription_id=self._config.subscription_id, @@ -729,41 +684,38 @@ def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("StorageContainers", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/storageContainers/{storageContainerName}" - } + return deserialized # type: ignore @overload def begin_update( @@ -787,14 +739,6 @@ def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either StorageContainers or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.StorageContainers] @@ -806,7 +750,7 @@ def begin_update( self, resource_group_name: str, storage_container_name: str, - storage_containers: IO, + storage_containers: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -819,18 +763,10 @@ def begin_update( :param storage_container_name: Name of the storage container. Required. :type storage_container_name: str :param storage_containers: Required. - :type storage_containers: IO + :type storage_containers: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either StorageContainers or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.StorageContainers] @@ -842,7 +778,7 @@ def begin_update( self, resource_group_name: str, storage_container_name: str, - storage_containers: Union[_models.StorageContainersUpdateRequest, IO], + storage_containers: Union[_models.StorageContainersUpdateRequest, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.StorageContainers]: """The operation to update a storage container. @@ -852,20 +788,10 @@ def begin_update( :type resource_group_name: str :param storage_container_name: Name of the storage container. Required. :type storage_container_name: str - :param storage_containers: Is either a StorageContainersUpdateRequest type or a IO type. + :param storage_containers: Is either a StorageContainersUpdateRequest type or a IO[bytes] type. Required. - :type storage_containers: ~azure.mgmt.azurestackhci.models.StorageContainersUpdateRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :type storage_containers: ~azure.mgmt.azurestackhci.models.StorageContainersUpdateRequest or + IO[bytes] :return: An instance of LROPoller that returns either StorageContainers or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.StorageContainers] @@ -892,12 +818,13 @@ def begin_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("StorageContainers", pipeline_response) + deserialized = self._deserialize("StorageContainers", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -909,17 +836,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.StorageContainers].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/storageContainers/{storageContainerName}" - } + return LROPoller[_models.StorageContainers]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.StorageContainers"]: @@ -929,7 +854,6 @@ def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Sto :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageContainers or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.StorageContainers] :raises ~azure.core.exceptions.HttpResponseError: @@ -940,7 +864,7 @@ def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Sto api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.StorageContainersListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -951,16 +875,14 @@ def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Sto def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -972,13 +894,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageContainersListResult", pipeline_response) @@ -988,11 +909,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1005,16 +926,11 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/storageContainers" - } - @distributed_trace def list_all(self, **kwargs: Any) -> Iterable["_models.StorageContainers"]: """Lists all of the storage containers in the specified subscription. Use the nextLink property in the response to get the next page of storage containers. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageContainers or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.StorageContainers] :raises ~azure.core.exceptions.HttpResponseError: @@ -1025,7 +941,7 @@ def list_all(self, **kwargs: Any) -> Iterable["_models.StorageContainers"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.StorageContainersListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1036,15 +952,13 @@ def list_all(self, **kwargs: Any) -> Iterable["_models.StorageContainers"]: def prepare_request(next_link=None): if not next_link: - request = build_list_all_request( + _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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1056,13 +970,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("StorageContainersListResult", pipeline_response) @@ -1072,11 +985,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1088,5 +1001,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_all.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/storageContainers"} diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_update_runs_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_update_runs_operations.py new file mode 100644 index 000000000000..0c227b397596 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_update_runs_operations.py @@ -0,0 +1,645 @@ +# pylint: disable=too-many-lines,too-many-statements +# 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 io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, cluster_name: str, update_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/updates/{updateName}/updateRuns", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "updateName": _SERIALIZER.url("update_name", update_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + cluster_name: str, + update_name: str, + update_run_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/updates/{updateName}/updateRuns/{updateRunName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "updateName": _SERIALIZER.url("update_name", update_name, "str"), + "updateRunName": _SERIALIZER.url("update_run_name", update_run_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_put_request( + resource_group_name: str, + cluster_name: str, + update_name: str, + update_run_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/updates/{updateName}/updateRuns/{updateRunName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "updateName": _SERIALIZER.url("update_name", update_name, "str"), + "updateRunName": _SERIALIZER.url("update_run_name", update_run_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, + cluster_name: str, + update_name: str, + update_run_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/updates/{updateName}/updateRuns/{updateRunName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "updateName": _SERIALIZER.url("update_name", update_name, "str"), + "updateRunName": _SERIALIZER.url("update_run_name", update_run_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class UpdateRunsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.azurestackhci.AzureStackHCIClient`'s + :attr:`update_runs` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, cluster_name: str, update_name: str, **kwargs: Any + ) -> Iterable["_models.UpdateRun"]: + """List all Update runs for a specified update. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param update_name: The name of the Update. Required. + :type update_name: str + :return: An iterator like instance of either UpdateRun or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.UpdateRun] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.UpdateRunList] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + update_name=update_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("UpdateRunList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + def _delete_initial( + self, resource_group_name: str, cluster_name: str, update_name: str, update_run_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + update_name=update_name, + update_run_name=update_run_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, cluster_name: str, update_name: str, update_run_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Delete specified Update Run. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param update_name: The name of the Update. Required. + :type update_name: str + :param update_run_name: The name of the Update Run. Required. + :type update_run_name: str + :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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + update_name=update_name, + update_run_name=update_run_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @overload + def put( + self, + resource_group_name: str, + cluster_name: str, + update_name: str, + update_run_name: str, + update_runs_properties: _models.UpdateRun, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UpdateRun: + """Put Update runs for a specified update. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param update_name: The name of the Update. Required. + :type update_name: str + :param update_run_name: The name of the Update Run. Required. + :type update_run_name: str + :param update_runs_properties: Properties of the updateRuns object. Required. + :type update_runs_properties: ~azure.mgmt.azurestackhci.models.UpdateRun + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: UpdateRun or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.UpdateRun + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def put( + self, + resource_group_name: str, + cluster_name: str, + update_name: str, + update_run_name: str, + update_runs_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UpdateRun: + """Put Update runs for a specified update. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param update_name: The name of the Update. Required. + :type update_name: str + :param update_run_name: The name of the Update Run. Required. + :type update_run_name: str + :param update_runs_properties: Properties of the updateRuns object. Required. + :type update_runs_properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: UpdateRun or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.UpdateRun + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def put( + self, + resource_group_name: str, + cluster_name: str, + update_name: str, + update_run_name: str, + update_runs_properties: Union[_models.UpdateRun, IO[bytes]], + **kwargs: Any + ) -> _models.UpdateRun: + """Put Update runs for a specified update. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param update_name: The name of the Update. Required. + :type update_name: str + :param update_run_name: The name of the Update Run. Required. + :type update_run_name: str + :param update_runs_properties: Properties of the updateRuns object. Is either a UpdateRun type + or a IO[bytes] type. Required. + :type update_runs_properties: ~azure.mgmt.azurestackhci.models.UpdateRun or IO[bytes] + :return: UpdateRun or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.UpdateRun + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.UpdateRun] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(update_runs_properties, (IOBase, bytes)): + _content = update_runs_properties + else: + _json = self._serialize.body(update_runs_properties, "UpdateRun") + + _request = build_put_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + update_name=update_name, + update_run_name=update_run_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("UpdateRun", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get( + self, resource_group_name: str, cluster_name: str, update_name: str, update_run_name: str, **kwargs: Any + ) -> _models.UpdateRun: + """Get the Update run for a specified update. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param update_name: The name of the Update. Required. + :type update_name: str + :param update_run_name: The name of the Update Run. Required. + :type update_run_name: str + :return: UpdateRun or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.UpdateRun + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.UpdateRun] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + update_name=update_name, + update_run_name=update_run_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("UpdateRun", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_update_summaries_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_update_summaries_operations.py new file mode 100644 index 000000000000..de95377eb05a --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_update_summaries_operations.py @@ -0,0 +1,572 @@ +# pylint: disable=too-many-lines,too-many-statements +# 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 io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request(resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/updateSummaries", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/updateSummaries/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_put_request(resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/updateSummaries/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/updateSummaries/default", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class UpdateSummariesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.azurestackhci.AzureStackHCIClient`'s + :attr:`update_summaries` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> Iterable["_models.UpdateSummaries"]: + """List all Update summaries under the HCI cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :return: An iterator like instance of either UpdateSummaries or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.UpdateSummaries] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.UpdateSummariesList] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("UpdateSummariesList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + def _delete_initial(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> LROPoller[None]: + """Delete Update Summaries. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @overload + def put( + self, + resource_group_name: str, + cluster_name: str, + update_location_properties: _models.UpdateSummaries, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UpdateSummaries: + """Put Update summaries under the HCI cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param update_location_properties: Properties of the UpdateSummaries resource. Required. + :type update_location_properties: ~azure.mgmt.azurestackhci.models.UpdateSummaries + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: UpdateSummaries or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.UpdateSummaries + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def put( + self, + resource_group_name: str, + cluster_name: str, + update_location_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.UpdateSummaries: + """Put Update summaries under the HCI cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param update_location_properties: Properties of the UpdateSummaries resource. Required. + :type update_location_properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: UpdateSummaries or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.UpdateSummaries + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def put( + self, + resource_group_name: str, + cluster_name: str, + update_location_properties: Union[_models.UpdateSummaries, IO[bytes]], + **kwargs: Any + ) -> _models.UpdateSummaries: + """Put Update summaries under the HCI cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param update_location_properties: Properties of the UpdateSummaries resource. Is either a + UpdateSummaries type or a IO[bytes] type. Required. + :type update_location_properties: ~azure.mgmt.azurestackhci.models.UpdateSummaries or IO[bytes] + :return: UpdateSummaries or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.UpdateSummaries + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.UpdateSummaries] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(update_location_properties, (IOBase, bytes)): + _content = update_location_properties + else: + _json = self._serialize.body(update_location_properties, "UpdateSummaries") + + _request = build_put_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("UpdateSummaries", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> _models.UpdateSummaries: + """Get all Update summaries under the HCI cluster. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :return: UpdateSummaries or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.UpdateSummaries + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.UpdateSummaries] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("UpdateSummaries", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_updates_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_updates_operations.py new file mode 100644 index 000000000000..132f961a5115 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_updates_operations.py @@ -0,0 +1,752 @@ +# pylint: disable=too-many-lines,too-many-statements +# 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 io import IOBase +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_post_request( + resource_group_name: str, cluster_name: str, update_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/updates/{updateName}/apply", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "updateName": _SERIALIZER.url("update_name", update_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request(resource_group_name: str, cluster_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/updates", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, cluster_name: str, update_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/updates/{updateName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "updateName": _SERIALIZER.url("update_name", update_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_put_request( + resource_group_name: str, cluster_name: str, update_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/updates/{updateName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "updateName": _SERIALIZER.url("update_name", update_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, cluster_name: str, update_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/updates/{updateName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "clusterName": _SERIALIZER.url("cluster_name", cluster_name, "str"), + "updateName": _SERIALIZER.url("update_name", update_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class UpdatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.azurestackhci.AzureStackHCIClient`'s + :attr:`updates` 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 _post_initial( + self, resource_group_name: str, cluster_name: str, update_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_post_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + update_name=update_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_post( + self, resource_group_name: str, cluster_name: str, update_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Apply Update. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param update_name: The name of the Update. Required. + :type update_name: str + :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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._post_initial( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + update_name=update_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @distributed_trace + def list(self, resource_group_name: str, cluster_name: str, **kwargs: Any) -> Iterable["_models.Update"]: + """List all Updates. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :return: An iterator like instance of either Update or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.Update] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.UpdateList] = kwargs.pop("cls", None) + + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_list_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request + + def extract_data(pipeline_response): + deserialized = self._deserialize("UpdateList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + def _delete_initial( + self, resource_group_name: str, cluster_name: str, update_name: str, **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + _request = build_delete_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + update_name=update_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_delete( + self, resource_group_name: str, cluster_name: str, update_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Delete specified Update. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param update_name: The name of the Update. Required. + :type update_name: str + :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: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + update_name=update_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[None].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + @overload + def put( + self, + resource_group_name: str, + cluster_name: str, + update_name: str, + update_properties: _models.Update, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Update: + """Put specified Update. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param update_name: The name of the Update. Required. + :type update_name: str + :param update_properties: Properties of the Updates object. Required. + :type update_properties: ~azure.mgmt.azurestackhci.models.Update + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Update or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.Update + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def put( + self, + resource_group_name: str, + cluster_name: str, + update_name: str, + update_properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Update: + """Put specified Update. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param update_name: The name of the Update. Required. + :type update_name: str + :param update_properties: Properties of the Updates object. Required. + :type update_properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: Update or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.Update + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def put( + self, + resource_group_name: str, + cluster_name: str, + update_name: str, + update_properties: Union[_models.Update, IO[bytes]], + **kwargs: Any + ) -> _models.Update: + """Put specified Update. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param update_name: The name of the Update. Required. + :type update_name: str + :param update_properties: Properties of the Updates object. Is either a Update type or a + IO[bytes] type. Required. + :type update_properties: ~azure.mgmt.azurestackhci.models.Update or IO[bytes] + :return: Update or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.Update + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Update] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(update_properties, (IOBase, bytes)): + _content = update_properties + else: + _json = self._serialize.body(update_properties, "Update") + + _request = build_put_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + update_name=update_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Update", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get(self, resource_group_name: str, cluster_name: str, update_name: str, **kwargs: Any) -> _models.Update: + """Get specified Update. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param cluster_name: The name of the cluster. Required. + :type cluster_name: str + :param update_name: The name of the Update. Required. + :type update_name: str + :return: Update or the result of cls(response) + :rtype: ~azure.mgmt.azurestackhci.models.Update + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping[int, Type[HttpResponseError]] = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.Update] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + cluster_name=cluster_name, + update_name=update_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + headers=_headers, + params=_params, + ) + _request.url = self._client.format_url(_request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Update", pipeline_response.http_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_virtual_hard_disks_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_virtual_hard_disks_operations.py index 362a1da6871c..dcfa5f77bef7 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_virtual_hard_disks_operations.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_virtual_hard_disks_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, 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.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +50,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -85,7 +90,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -128,7 +133,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -168,7 +173,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -209,7 +214,7 @@ def build_list_request(resource_group_name: str, subscription_id: str, **kwargs: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -239,7 +244,7 @@ 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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -289,12 +294,11 @@ def get(self, resource_group_name: str, virtual_hard_disk_name: str, **kwargs: A :type resource_group_name: str :param virtual_hard_disk_name: Name of the virtual hard disk. Required. :type virtual_hard_disk_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: VirtualHardDisks or the result of cls(response) :rtype: ~azure.mgmt.azurestackhci.models.VirtualHardDisks :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -308,21 +312,19 @@ def get(self, resource_group_name: str, virtual_hard_disk_name: str, **kwargs: A api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.VirtualHardDisks] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, virtual_hard_disk_name=virtual_hard_disk_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -332,25 +334,21 @@ def get(self, resource_group_name: str, virtual_hard_disk_name: str, **kwargs: A error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("VirtualHardDisks", pipeline_response) + deserialized = self._deserialize("VirtualHardDisks", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualHardDisks/{virtualHardDiskName}" - } + return deserialized # type: ignore def _create_or_update_initial( self, resource_group_name: str, virtual_hard_disk_name: str, - virtual_hard_disks: Union[_models.VirtualHardDisks, IO], + virtual_hard_disks: Union[_models.VirtualHardDisks, IO[bytes]], **kwargs: Any - ) -> _models.VirtualHardDisks: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -363,7 +361,7 @@ def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualHardDisks] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -373,7 +371,7 @@ def _create_or_update_initial( else: _json = self._serialize.body(virtual_hard_disks, "VirtualHardDisks") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, virtual_hard_disk_name=virtual_hard_disk_name, subscription_id=self._config.subscription_id, @@ -381,40 +379,35 @@ def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("VirtualHardDisks", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("VirtualHardDisks", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualHardDisks/{virtualHardDiskName}" - } - @overload def begin_create_or_update( self, @@ -438,14 +431,6 @@ def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either VirtualHardDisks or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.VirtualHardDisks] @@ -457,7 +442,7 @@ def begin_create_or_update( self, resource_group_name: str, virtual_hard_disk_name: str, - virtual_hard_disks: IO, + virtual_hard_disks: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -471,18 +456,10 @@ def begin_create_or_update( :param virtual_hard_disk_name: Name of the virtual hard disk. Required. :type virtual_hard_disk_name: str :param virtual_hard_disks: Required. - :type virtual_hard_disks: IO + :type virtual_hard_disks: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either VirtualHardDisks or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.VirtualHardDisks] @@ -494,7 +471,7 @@ def begin_create_or_update( self, resource_group_name: str, virtual_hard_disk_name: str, - virtual_hard_disks: Union[_models.VirtualHardDisks, IO], + virtual_hard_disks: Union[_models.VirtualHardDisks, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.VirtualHardDisks]: """The operation to create or update a virtual hard disk. Please note some properties can be set @@ -505,19 +482,8 @@ def begin_create_or_update( :type resource_group_name: str :param virtual_hard_disk_name: Name of the virtual hard disk. Required. :type virtual_hard_disk_name: str - :param virtual_hard_disks: Is either a VirtualHardDisks type or a IO type. Required. - :type virtual_hard_disks: ~azure.mgmt.azurestackhci.models.VirtualHardDisks or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :param virtual_hard_disks: Is either a VirtualHardDisks type or a IO[bytes] type. Required. + :type virtual_hard_disks: ~azure.mgmt.azurestackhci.models.VirtualHardDisks or IO[bytes] :return: An instance of LROPoller that returns either VirtualHardDisks or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.VirtualHardDisks] @@ -544,12 +510,13 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualHardDisks", pipeline_response) + deserialized = self._deserialize("VirtualHardDisks", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -561,22 +528,18 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.VirtualHardDisks].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualHardDisks/{virtualHardDiskName}" - } + return LROPoller[_models.VirtualHardDisks]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_group_name: str, virtual_hard_disk_name: str, **kwargs: Any - ) -> None: - error_map = { + def _delete_initial(self, resource_group_name: str, virtual_hard_disk_name: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -588,28 +551,31 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, virtual_hard_disk_name=virtual_hard_disk_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) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -618,12 +584,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualHardDisks/{virtualHardDiskName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete(self, resource_group_name: str, virtual_hard_disk_name: str, **kwargs: Any) -> LROPoller[None]: @@ -634,14 +600,6 @@ def begin_delete(self, resource_group_name: str, virtual_hard_disk_name: str, ** :type resource_group_name: str :param virtual_hard_disk_name: Name of the virtual hard disk. Required. :type virtual_hard_disk_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: @@ -655,7 +613,7 @@ def begin_delete(self, resource_group_name: str, virtual_hard_disk_name: str, ** lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_group_name=resource_group_name, virtual_hard_disk_name=virtual_hard_disk_name, api_version=api_version, @@ -664,11 +622,12 @@ def begin_delete(self, resource_group_name: str, virtual_hard_disk_name: str, ** params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -679,26 +638,22 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualHardDisks/{virtualHardDiskName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _update_initial( self, resource_group_name: str, virtual_hard_disk_name: str, - virtual_hard_disks: Union[_models.VirtualHardDisksUpdateRequest, IO], + virtual_hard_disks: Union[_models.VirtualHardDisksUpdateRequest, IO[bytes]], **kwargs: Any - ) -> Optional[_models.VirtualHardDisks]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -711,7 +666,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.VirtualHardDisks]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -721,7 +676,7 @@ def _update_initial( else: _json = self._serialize.body(virtual_hard_disks, "VirtualHardDisksUpdateRequest") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, virtual_hard_disk_name=virtual_hard_disk_name, subscription_id=self._config.subscription_id, @@ -729,41 +684,38 @@ def _update_initial( content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("VirtualHardDisks", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualHardDisks/{virtualHardDiskName}" - } + return deserialized # type: ignore @overload def begin_update( @@ -787,14 +739,6 @@ def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either VirtualHardDisks or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.VirtualHardDisks] @@ -806,7 +750,7 @@ def begin_update( self, resource_group_name: str, virtual_hard_disk_name: str, - virtual_hard_disks: IO, + virtual_hard_disks: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -819,18 +763,10 @@ def begin_update( :param virtual_hard_disk_name: Name of the virtual hard disk. Required. :type virtual_hard_disk_name: str :param virtual_hard_disks: Required. - :type virtual_hard_disks: IO + :type virtual_hard_disks: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either VirtualHardDisks or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.VirtualHardDisks] @@ -842,7 +778,7 @@ def begin_update( self, resource_group_name: str, virtual_hard_disk_name: str, - virtual_hard_disks: Union[_models.VirtualHardDisksUpdateRequest, IO], + virtual_hard_disks: Union[_models.VirtualHardDisksUpdateRequest, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.VirtualHardDisks]: """The operation to update a virtual hard disk. @@ -852,20 +788,10 @@ def begin_update( :type resource_group_name: str :param virtual_hard_disk_name: Name of the virtual hard disk. Required. :type virtual_hard_disk_name: str - :param virtual_hard_disks: Is either a VirtualHardDisksUpdateRequest type or a IO type. + :param virtual_hard_disks: Is either a VirtualHardDisksUpdateRequest type or a IO[bytes] type. Required. - :type virtual_hard_disks: ~azure.mgmt.azurestackhci.models.VirtualHardDisksUpdateRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :type virtual_hard_disks: ~azure.mgmt.azurestackhci.models.VirtualHardDisksUpdateRequest or + IO[bytes] :return: An instance of LROPoller that returns either VirtualHardDisks or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.VirtualHardDisks] @@ -892,12 +818,13 @@ def begin_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualHardDisks", pipeline_response) + deserialized = self._deserialize("VirtualHardDisks", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -909,17 +836,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.VirtualHardDisks].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualHardDisks/{virtualHardDiskName}" - } + return LROPoller[_models.VirtualHardDisks]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.VirtualHardDisks"]: @@ -929,7 +854,6 @@ def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Vir :param resource_group_name: The name of the resource group. The name is case insensitive. Required. :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either VirtualHardDisks or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.VirtualHardDisks] :raises ~azure.core.exceptions.HttpResponseError: @@ -940,7 +864,7 @@ def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Vir api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.VirtualHardDisksListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -951,16 +875,14 @@ def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Vir def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -972,13 +894,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("VirtualHardDisksListResult", pipeline_response) @@ -988,11 +909,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1005,16 +926,11 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/virtualHardDisks" - } - @distributed_trace def list_all(self, **kwargs: Any) -> Iterable["_models.VirtualHardDisks"]: """Lists all of the virtual hard disks in the specified subscription. Use the nextLink property in the response to get the next page of virtual hard disks. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either VirtualHardDisks or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.VirtualHardDisks] :raises ~azure.core.exceptions.HttpResponseError: @@ -1025,7 +941,7 @@ def list_all(self, **kwargs: Any) -> Iterable["_models.VirtualHardDisks"]: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.VirtualHardDisksListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1036,15 +952,13 @@ def list_all(self, **kwargs: Any) -> Iterable["_models.VirtualHardDisks"]: def prepare_request(next_link=None): if not next_link: - request = build_list_all_request( + _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) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1056,13 +970,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("VirtualHardDisksListResult", pipeline_response) @@ -1072,11 +985,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1088,5 +1001,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_all.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/virtualHardDisks"} diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_virtual_machine_instances_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_virtual_machine_instances_operations.py index 2e05da9096df..18005c9e6222 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_virtual_machine_instances_operations.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/azure/mgmt/azurestackhci/operations/_virtual_machine_instances_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -7,7 +7,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase -from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import sys +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -16,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, 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.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -30,8 +32,11 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -43,7 +48,7 @@ def build_get_request(resource_uri: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -69,7 +74,7 @@ def build_create_or_update_request(resource_uri: str, **kwargs: Any) -> HttpRequ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -98,7 +103,7 @@ def build_delete_request(resource_uri: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -124,7 +129,7 @@ def build_update_request(resource_uri: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -153,7 +158,7 @@ def build_start_request(resource_uri: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -179,7 +184,7 @@ def build_stop_request(resource_uri: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -205,7 +210,7 @@ def build_restart_request(resource_uri: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -231,7 +236,7 @@ def build_list_request(resource_uri: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-09-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-01-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -277,12 +282,11 @@ def get(self, resource_uri: str, **kwargs: Any) -> _models.VirtualMachineInstanc :param resource_uri: The fully qualified Azure Resource manager identifier of the Hybrid Compute machine resource to be extended. Required. :type resource_uri: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: VirtualMachineInstance or the result of cls(response) :rtype: ~azure.mgmt.azurestackhci.models.VirtualMachineInstance :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -296,19 +300,17 @@ def get(self, resource_uri: str, **kwargs: Any) -> _models.VirtualMachineInstanc api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.VirtualMachineInstance] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_uri=resource_uri, api_version=api_version, - template_url=self.get.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -318,19 +320,20 @@ def get(self, resource_uri: str, **kwargs: Any) -> _models.VirtualMachineInstanc error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("VirtualMachineInstance", pipeline_response) + deserialized = self._deserialize("VirtualMachineInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = {"url": "/{resourceUri}/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default"} + return deserialized # type: ignore def _create_or_update_initial( - self, resource_uri: str, virtual_machine_instance: Union[_models.VirtualMachineInstance, IO], **kwargs: Any - ) -> _models.VirtualMachineInstance: - error_map = { + self, + resource_uri: str, + virtual_machine_instance: Union[_models.VirtualMachineInstance, IO[bytes]], + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -343,7 +346,7 @@ def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.VirtualMachineInstance] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -353,46 +356,41 @@ def _create_or_update_initial( else: _json = self._serialize.body(virtual_machine_instance, "VirtualMachineInstance") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_uri=resource_uri, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("VirtualMachineInstance", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("VirtualMachineInstance", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/{resourceUri}/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default" - } - @overload def begin_create_or_update( self, @@ -413,14 +411,6 @@ def begin_create_or_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either VirtualMachineInstance or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.VirtualMachineInstance] @@ -429,7 +419,12 @@ def begin_create_or_update( @overload def begin_create_or_update( - self, resource_uri: str, virtual_machine_instance: IO, *, content_type: str = "application/json", **kwargs: Any + self, + resource_uri: str, + virtual_machine_instance: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any ) -> LROPoller[_models.VirtualMachineInstance]: """The operation to create or update a virtual machine instance. Please note some properties can be set only during virtual machine instance creation. @@ -438,18 +433,10 @@ def begin_create_or_update( Compute machine resource to be extended. Required. :type resource_uri: str :param virtual_machine_instance: Required. - :type virtual_machine_instance: IO + :type virtual_machine_instance: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either VirtualMachineInstance or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.VirtualMachineInstance] @@ -458,7 +445,10 @@ def begin_create_or_update( @distributed_trace def begin_create_or_update( - self, resource_uri: str, virtual_machine_instance: Union[_models.VirtualMachineInstance, IO], **kwargs: Any + self, + resource_uri: str, + virtual_machine_instance: Union[_models.VirtualMachineInstance, IO[bytes]], + **kwargs: Any ) -> LROPoller[_models.VirtualMachineInstance]: """The operation to create or update a virtual machine instance. Please note some properties can be set only during virtual machine instance creation. @@ -466,20 +456,10 @@ def begin_create_or_update( :param resource_uri: The fully qualified Azure Resource manager identifier of the Hybrid Compute machine resource to be extended. Required. :type resource_uri: str - :param virtual_machine_instance: Is either a VirtualMachineInstance type or a IO type. + :param virtual_machine_instance: Is either a VirtualMachineInstance type or a IO[bytes] type. Required. - :type virtual_machine_instance: ~azure.mgmt.azurestackhci.models.VirtualMachineInstance or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + :type virtual_machine_instance: ~azure.mgmt.azurestackhci.models.VirtualMachineInstance or + IO[bytes] :return: An instance of LROPoller that returns either VirtualMachineInstance or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.VirtualMachineInstance] @@ -505,12 +485,13 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineInstance", pipeline_response) + deserialized = self._deserialize("VirtualMachineInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -522,22 +503,18 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.VirtualMachineInstance].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_create_or_update.metadata = { - "url": "/{resourceUri}/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default" - } + return LROPoller[_models.VirtualMachineInstance]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _delete_initial( # pylint: disable=inconsistent-return-statements - self, resource_uri: str, **kwargs: Any - ) -> None: - error_map = { + def _delete_initial(self, resource_uri: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -549,26 +526,29 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_uri=resource_uri, api_version=api_version, - template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [202, 204]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -577,12 +557,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/{resourceUri}/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default" - } + return deserialized # type: ignore @distributed_trace def begin_delete(self, resource_uri: str, **kwargs: Any) -> LROPoller[None]: @@ -591,14 +571,6 @@ def begin_delete(self, resource_uri: str, **kwargs: Any) -> LROPoller[None]: :param resource_uri: The fully qualified Azure Resource manager identifier of the Hybrid Compute machine resource to be extended. Required. :type resource_uri: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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: @@ -612,7 +584,7 @@ def begin_delete(self, resource_uri: str, **kwargs: Any) -> LROPoller[None]: lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._delete_initial( # type: ignore + raw_result = self._delete_initial( resource_uri=resource_uri, api_version=api_version, cls=lambda x, y, z: x, @@ -620,11 +592,12 @@ def begin_delete(self, resource_uri: str, **kwargs: Any) -> LROPoller[None]: params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -635,23 +608,21 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_delete.metadata = {"url": "/{resourceUri}/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default"} + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _update_initial( self, resource_uri: str, - virtual_machine_instance: Union[_models.VirtualMachineInstanceUpdateRequest, IO], + virtual_machine_instance: Union[_models.VirtualMachineInstanceUpdateRequest, IO[bytes]], **kwargs: Any - ) -> Optional[_models.VirtualMachineInstance]: - error_map = { + ) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -664,7 +635,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.VirtualMachineInstance]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -674,47 +645,44 @@ def _update_initial( else: _json = self._serialize.body(virtual_machine_instance, "VirtualMachineInstanceUpdateRequest") - request = build_update_request( + _request = build_update_request( resource_uri=resource_uri, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self._update_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("VirtualMachineInstance", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _update_initial.metadata = { - "url": "/{resourceUri}/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default" - } + return deserialized # type: ignore @overload def begin_update( @@ -736,14 +704,6 @@ def begin_update( :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either VirtualMachineInstance or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.VirtualMachineInstance] @@ -752,7 +712,12 @@ def begin_update( @overload def begin_update( - self, resource_uri: str, virtual_machine_instance: IO, *, content_type: str = "application/json", **kwargs: Any + self, + resource_uri: str, + virtual_machine_instance: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any ) -> LROPoller[_models.VirtualMachineInstance]: """The operation to update a virtual machine instance. @@ -760,18 +725,10 @@ def begin_update( Compute machine resource to be extended. Required. :type resource_uri: str :param virtual_machine_instance: Required. - :type virtual_machine_instance: IO + :type virtual_machine_instance: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. :return: An instance of LROPoller that returns either VirtualMachineInstance or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.VirtualMachineInstance] @@ -782,7 +739,7 @@ def begin_update( def begin_update( self, resource_uri: str, - virtual_machine_instance: Union[_models.VirtualMachineInstanceUpdateRequest, IO], + virtual_machine_instance: Union[_models.VirtualMachineInstanceUpdateRequest, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.VirtualMachineInstance]: """The operation to update a virtual machine instance. @@ -790,21 +747,10 @@ def begin_update( :param resource_uri: The fully qualified Azure Resource manager identifier of the Hybrid Compute machine resource to be extended. Required. :type resource_uri: str - :param virtual_machine_instance: Is either a VirtualMachineInstanceUpdateRequest type or a IO - type. Required. + :param virtual_machine_instance: Is either a VirtualMachineInstanceUpdateRequest type or a + IO[bytes] type. Required. :type virtual_machine_instance: - ~azure.mgmt.azurestackhci.models.VirtualMachineInstanceUpdateRequest or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. + ~azure.mgmt.azurestackhci.models.VirtualMachineInstanceUpdateRequest or IO[bytes] :return: An instance of LROPoller that returns either VirtualMachineInstance or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.VirtualMachineInstance] @@ -830,12 +776,13 @@ def begin_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineInstance", pipeline_response) + deserialized = self._deserialize("VirtualMachineInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -847,18 +794,18 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.VirtualMachineInstance].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_update.metadata = {"url": "/{resourceUri}/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default"} + return LROPoller[_models.VirtualMachineInstance]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _start_initial(self, resource_uri: str, **kwargs: Any) -> Optional[_models.VirtualMachineInstance]: - error_map = { + def _start_initial(self, resource_uri: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -870,46 +817,43 @@ def _start_initial(self, resource_uri: str, **kwargs: Any) -> Optional[_models.V _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[Optional[_models.VirtualMachineInstance]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_start_request( + _request = build_start_request( resource_uri=resource_uri, 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("VirtualMachineInstance", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _start_initial.metadata = { - "url": "/{resourceUri}/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default/start" - } + return deserialized # type: ignore @distributed_trace def begin_start(self, resource_uri: str, **kwargs: Any) -> LROPoller[_models.VirtualMachineInstance]: @@ -918,14 +862,6 @@ def begin_start(self, resource_uri: str, **kwargs: Any) -> LROPoller[_models.Vir :param resource_uri: The fully qualified Azure Resource manager identifier of the Hybrid Compute machine resource to be extended. Required. :type resource_uri: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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 VirtualMachineInstance or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.VirtualMachineInstance] @@ -948,12 +884,13 @@ def begin_start(self, resource_uri: str, **kwargs: Any) -> LROPoller[_models.Vir params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineInstance", pipeline_response) + deserialized = self._deserialize("VirtualMachineInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -965,20 +902,18 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.VirtualMachineInstance].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_start.metadata = { - "url": "/{resourceUri}/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default/start" - } + return LROPoller[_models.VirtualMachineInstance]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _stop_initial(self, resource_uri: str, **kwargs: Any) -> Optional[_models.VirtualMachineInstance]: - error_map = { + def _stop_initial(self, resource_uri: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -990,46 +925,43 @@ def _stop_initial(self, resource_uri: str, **kwargs: Any) -> Optional[_models.Vi _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[Optional[_models.VirtualMachineInstance]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_stop_request( + _request = build_stop_request( resource_uri=resource_uri, api_version=api_version, - template_url=self._stop_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("VirtualMachineInstance", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _stop_initial.metadata = { - "url": "/{resourceUri}/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default/stop" - } + return deserialized # type: ignore @distributed_trace def begin_stop(self, resource_uri: str, **kwargs: Any) -> LROPoller[_models.VirtualMachineInstance]: @@ -1038,14 +970,6 @@ def begin_stop(self, resource_uri: str, **kwargs: Any) -> LROPoller[_models.Virt :param resource_uri: The fully qualified Azure Resource manager identifier of the Hybrid Compute machine resource to be extended. Required. :type resource_uri: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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 VirtualMachineInstance or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.VirtualMachineInstance] @@ -1068,12 +992,13 @@ def begin_stop(self, resource_uri: str, **kwargs: Any) -> LROPoller[_models.Virt params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineInstance", pipeline_response) + deserialized = self._deserialize("VirtualMachineInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1085,20 +1010,18 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.VirtualMachineInstance].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_stop.metadata = { - "url": "/{resourceUri}/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default/stop" - } + return LROPoller[_models.VirtualMachineInstance]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) - def _restart_initial(self, resource_uri: str, **kwargs: Any) -> Optional[_models.VirtualMachineInstance]: - error_map = { + def _restart_initial(self, resource_uri: str, **kwargs: Any) -> Iterator[bytes]: + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1110,46 +1033,43 @@ def _restart_initial(self, resource_uri: str, **kwargs: Any) -> Optional[_models _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[Optional[_models.VirtualMachineInstance]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - request = build_restart_request( + _request = build_restart_request( resource_uri=resource_uri, 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) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 202]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("VirtualMachineInstance", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - if cls: - return cls(pipeline_response, deserialized, response_headers) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - return deserialized + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _restart_initial.metadata = { - "url": "/{resourceUri}/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default/restart" - } + return deserialized # type: ignore @distributed_trace def begin_restart(self, resource_uri: str, **kwargs: Any) -> LROPoller[_models.VirtualMachineInstance]: @@ -1158,14 +1078,6 @@ def begin_restart(self, resource_uri: str, **kwargs: Any) -> LROPoller[_models.V :param resource_uri: The fully qualified Azure Resource manager identifier of the Hybrid Compute machine resource to be extended. Required. :type resource_uri: str - :keyword callable cls: A custom type or function that will be passed the direct response - :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 VirtualMachineInstance or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.azurestackhci.models.VirtualMachineInstance] @@ -1188,12 +1100,13 @@ def begin_restart(self, resource_uri: str, **kwargs: Any) -> LROPoller[_models.V params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("VirtualMachineInstance", pipeline_response) + deserialized = self._deserialize("VirtualMachineInstance", pipeline_response.http_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1205,17 +1118,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.VirtualMachineInstance].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - begin_restart.metadata = { - "url": "/{resourceUri}/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default/restart" - } + return LROPoller[_models.VirtualMachineInstance]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def list(self, resource_uri: str, **kwargs: Any) -> Iterable["_models.VirtualMachineInstance"]: @@ -1224,7 +1135,6 @@ def list(self, resource_uri: str, **kwargs: Any) -> Iterable["_models.VirtualMac :param resource_uri: The fully qualified Azure Resource manager identifier of the Hybrid Compute machine resource to be extended. Required. :type resource_uri: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either VirtualMachineInstance or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.azurestackhci.models.VirtualMachineInstance] @@ -1236,7 +1146,7 @@ def list(self, resource_uri: str, **kwargs: Any) -> Iterable["_models.VirtualMac api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.VirtualMachineInstanceListResult] = kwargs.pop("cls", None) - error_map = { + error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, @@ -1247,15 +1157,13 @@ def list(self, resource_uri: str, **kwargs: Any) -> Iterable["_models.VirtualMac def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_uri=resource_uri, api_version=api_version, - template_url=self.list.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1267,13 +1175,12 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request.url = self._client.format_url(_request.url) + _request.method = "GET" + return _request def extract_data(pipeline_response): deserialized = self._deserialize("VirtualMachineInstanceListResult", pipeline_response) @@ -1283,11 +1190,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1299,5 +1206,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/{resourceUri}/providers/Microsoft.AzureStackHCI/virtualMachineInstances"} diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/consent_and_install_default_extensions.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/consent_and_install_default_extensions.py new file mode 100644 index 000000000000..470402d8a3fa --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/consent_and_install_default_extensions.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.azurestackhci import AzureStackHCIClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-azurestackhci +# USAGE + python consent_and_install_default_extensions.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AzureStackHCIClient( + credential=DefaultAzureCredential(), + subscription_id="fd3c3665-1729-4b7b-9a38-238e83b0f98b", + ) + + response = client.arc_settings.consent_and_install_default_extensions( + resource_group_name="test-rg", + cluster_name="myCluster", + arc_setting_name="default", + ) + print(response) + + +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/ConsentAndInstallDefaultExtensions.json +if __name__ == "__main__": + main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/create_arc_identity.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/create_arc_identity.py new file mode 100644 index 000000000000..084cf2f33781 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/create_arc_identity.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.azurestackhci import AzureStackHCIClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-azurestackhci +# USAGE + python create_arc_identity.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AzureStackHCIClient( + credential=DefaultAzureCredential(), + subscription_id="fd3c3665-1729-4b7b-9a38-238e83b0f98b", + ) + + response = client.arc_settings.begin_create_identity( + resource_group_name="test-rg", + cluster_name="myCluster", + arc_setting_name="default", + ).result() + print(response) + + +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/CreateArcIdentity.json +if __name__ == "__main__": + main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/create_cluster.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/create_cluster.py new file mode 100644 index 000000000000..b5fbb2399f5f --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/create_cluster.py @@ -0,0 +1,51 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.azurestackhci import AzureStackHCIClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-azurestackhci +# USAGE + python create_cluster.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AzureStackHCIClient( + credential=DefaultAzureCredential(), + subscription_id="fd3c3665-1729-4b7b-9a38-238e83b0f98b", + ) + + response = client.clusters.create( + resource_group_name="test-rg", + cluster_name="myCluster", + cluster={ + "identity": {"type": "SystemAssigned"}, + "location": "East US", + "properties": { + "aadClientId": "24a6e53d-04e5-44d2-b7cc-1b732a847dfc", + "aadTenantId": "7e589cc1-a8b6-4dff-91bd-5ec0fa18db94", + "cloudManagementEndpoint": "https://98294836-31be-4668-aeae-698667faf99b.waconazure.com", + }, + }, + ) + print(response) + + +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/CreateCluster.json +if __name__ == "__main__": + main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/create_cluster_identity.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/create_cluster_identity.py new file mode 100644 index 000000000000..b32e018a9bf3 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/create_cluster_identity.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.azurestackhci import AzureStackHCIClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-azurestackhci +# USAGE + python create_cluster_identity.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AzureStackHCIClient( + credential=DefaultAzureCredential(), + subscription_id="fd3c3665-1729-4b7b-9a38-238e83b0f98b", + ) + + response = client.clusters.begin_create_identity( + resource_group_name="test-rg", + cluster_name="myCluster", + ).result() + print(response) + + +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/CreateClusterIdentity.json +if __name__ == "__main__": + main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/create_guest_agent.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/create_guest_agent.py index de4e356495cb..555b6f76929b 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/create_guest_agent.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/create_guest_agent.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.azurestackhci import AzureStackHCIClient """ @@ -35,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/preview/2023-09-01-preview/examples/CreateGuestAgent.json +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/CreateGuestAgent.json if __name__ == "__main__": main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_arc_setting.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_arc_setting.py new file mode 100644 index 000000000000..423ba091f354 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_arc_setting.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.azurestackhci import AzureStackHCIClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-azurestackhci +# USAGE + python delete_arc_setting.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AzureStackHCIClient( + credential=DefaultAzureCredential(), + subscription_id="fd3c3665-1729-4b7b-9a38-238e83b0f98b", + ) + + client.arc_settings.begin_delete( + resource_group_name="test-rg", + cluster_name="myCluster", + arc_setting_name="default", + ).result() + + +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/DeleteArcSetting.json +if __name__ == "__main__": + main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_cluster.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_cluster.py new file mode 100644 index 000000000000..97ee564ba668 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_cluster.py @@ -0,0 +1,41 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.azurestackhci import AzureStackHCIClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-azurestackhci +# USAGE + python delete_cluster.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AzureStackHCIClient( + credential=DefaultAzureCredential(), + subscription_id="fd3c3665-1729-4b7b-9a38-238e83b0f98b", + ) + + client.clusters.begin_delete( + resource_group_name="test-rg", + cluster_name="myCluster", + ).result() + + +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/DeleteCluster.json +if __name__ == "__main__": + main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_deployment_settings.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_deployment_settings.py new file mode 100644 index 000000000000..82822c47eba8 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_deployment_settings.py @@ -0,0 +1,41 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.azurestackhci import AzureStackHCIClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-azurestackhci +# USAGE + python delete_deployment_settings.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AzureStackHCIClient( + credential=DefaultAzureCredential(), + subscription_id="fd3c3665-1729-4b7b-9a38-238e83b0f98b", + ) + + client.deployment_settings.begin_delete( + resource_group_name="test-rg", + cluster_name="myCluster", + ).result() + + +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/DeleteDeploymentSettings.json +if __name__ == "__main__": + main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_edge_devices.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_edge_devices.py new file mode 100644 index 000000000000..63aa33639f25 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_edge_devices.py @@ -0,0 +1,40 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.azurestackhci import AzureStackHCIClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-azurestackhci +# USAGE + python delete_edge_devices.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AzureStackHCIClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + client.edge_devices.begin_delete( + resource_uri="subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/ArcInstance-rg/providers/Microsoft.HybridCompute/machines/Node-1", + ).result() + + +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/DeleteEdgeDevices.json +if __name__ == "__main__": + main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_extension.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_extension.py new file mode 100644 index 000000000000..b4d5e43c9329 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_extension.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.azurestackhci import AzureStackHCIClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-azurestackhci +# USAGE + python delete_extension.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AzureStackHCIClient( + credential=DefaultAzureCredential(), + subscription_id="fd3c3665-1729-4b7b-9a38-238e83b0f98b", + ) + + client.extensions.begin_delete( + resource_group_name="test-rg", + cluster_name="myCluster", + arc_setting_name="default", + extension_name="MicrosoftMonitoringAgent", + ).result() + + +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/DeleteExtension.json +if __name__ == "__main__": + main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_gallery_image.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_gallery_image.py index ed46f9dd01fa..e25888dd5cc1 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_gallery_image.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_gallery_image.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.azurestackhci import AzureStackHCIClient """ @@ -35,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/preview/2023-09-01-preview/examples/DeleteGalleryImage.json +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/DeleteGalleryImage.json if __name__ == "__main__": main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_guest_agent.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_guest_agent.py index 14e4dc628cc1..79812802260c 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_guest_agent.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_guest_agent.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.azurestackhci import AzureStackHCIClient """ @@ -34,6 +35,6 @@ def main(): ).result() -# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/preview/2023-09-01-preview/examples/DeleteGuestAgent.json +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/DeleteGuestAgent.json if __name__ == "__main__": main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_logical_network.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_logical_network.py index b7c7c8871a8d..7f5fb28c1bfb 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_logical_network.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_logical_network.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.azurestackhci import AzureStackHCIClient """ @@ -35,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/preview/2023-09-01-preview/examples/DeleteLogicalNetwork.json +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/DeleteLogicalNetwork.json if __name__ == "__main__": main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_marketplace_gallery_image.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_marketplace_gallery_image.py index 73f1480b9b87..80d1adf22920 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_marketplace_gallery_image.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_marketplace_gallery_image.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.azurestackhci import AzureStackHCIClient """ @@ -35,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/preview/2023-09-01-preview/examples/DeleteMarketplaceGalleryImage.json +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/DeleteMarketplaceGalleryImage.json if __name__ == "__main__": main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_network_interface.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_network_interface.py index 851d9dd4ad7e..a4c277cde23b 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_network_interface.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_network_interface.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.azurestackhci import AzureStackHCIClient """ @@ -35,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/preview/2023-09-01-preview/examples/DeleteNetworkInterface.json +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/DeleteNetworkInterface.json if __name__ == "__main__": main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_security_settings.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_security_settings.py new file mode 100644 index 000000000000..64e0fff6a911 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_security_settings.py @@ -0,0 +1,41 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.azurestackhci import AzureStackHCIClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-azurestackhci +# USAGE + python delete_security_settings.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AzureStackHCIClient( + credential=DefaultAzureCredential(), + subscription_id="fd3c3665-1729-4b7b-9a38-238e83b0f98b", + ) + + client.security_settings.begin_delete( + resource_group_name="test-rg", + cluster_name="myCluster", + ).result() + + +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/DeleteSecuritySettings.json +if __name__ == "__main__": + main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_storage_container.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_storage_container.py index dfee180a9e3c..7660f08a413a 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_storage_container.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_storage_container.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.azurestackhci import AzureStackHCIClient """ @@ -35,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/preview/2023-09-01-preview/examples/DeleteStorageContainer.json +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/DeleteStorageContainer.json if __name__ == "__main__": main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_update_runs.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_update_runs.py new file mode 100644 index 000000000000..c21b2e9e815e --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_update_runs.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.azurestackhci import AzureStackHCIClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-azurestackhci +# USAGE + python delete_update_runs.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AzureStackHCIClient( + credential=DefaultAzureCredential(), + subscription_id="b8d594e5-51f3-4c11-9c54-a7771b81c712", + ) + + client.update_runs.begin_delete( + resource_group_name="testrg", + cluster_name="testcluster", + update_name="Microsoft4.2203.2.32", + update_run_name="23b779ba-0d52-4a80-8571-45ca74664ec3", + ).result() + + +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/DeleteUpdateRuns.json +if __name__ == "__main__": + main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_update_summaries.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_update_summaries.py new file mode 100644 index 000000000000..e08c29bb07bb --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_update_summaries.py @@ -0,0 +1,41 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.azurestackhci import AzureStackHCIClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-azurestackhci +# USAGE + python delete_update_summaries.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AzureStackHCIClient( + credential=DefaultAzureCredential(), + subscription_id="b8d594e5-51f3-4c11-9c54-a7771b81c712", + ) + + client.update_summaries.begin_delete( + resource_group_name="testrg", + cluster_name="testcluster", + ).result() + + +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/DeleteUpdateSummaries.json +if __name__ == "__main__": + main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_updates.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_updates.py new file mode 100644 index 000000000000..dc5b28b7b6e6 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_updates.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.azurestackhci import AzureStackHCIClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-azurestackhci +# USAGE + python delete_updates.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AzureStackHCIClient( + credential=DefaultAzureCredential(), + subscription_id="b8d594e5-51f3-4c11-9c54-a7771b81c712", + ) + + client.updates.begin_delete( + resource_group_name="testrg", + cluster_name="testcluster", + update_name="Microsoft4.2203.2.32", + ).result() + + +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/DeleteUpdates.json +if __name__ == "__main__": + main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_virtual_hard_disk.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_virtual_hard_disk.py index ebbf27456b1b..5420af0e2c5a 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_virtual_hard_disk.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_virtual_hard_disk.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.azurestackhci import AzureStackHCIClient """ @@ -35,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/preview/2023-09-01-preview/examples/DeleteVirtualHardDisk.json +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/DeleteVirtualHardDisk.json if __name__ == "__main__": main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_virtual_machine_instance.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_virtual_machine_instance.py index 3d630b256dce..7272513b9a4f 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_virtual_machine_instance.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/delete_virtual_machine_instance.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.azurestackhci import AzureStackHCIClient """ @@ -34,6 +35,6 @@ def main(): ).result() -# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/preview/2023-09-01-preview/examples/DeleteVirtualMachineInstance.json +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/DeleteVirtualMachineInstance.json if __name__ == "__main__": main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/extend_software_assurance_benefit.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/extend_software_assurance_benefit.py new file mode 100644 index 000000000000..b49601d4f72b --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/extend_software_assurance_benefit.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.azurestackhci import AzureStackHCIClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-azurestackhci +# USAGE + python extend_software_assurance_benefit.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AzureStackHCIClient( + credential=DefaultAzureCredential(), + subscription_id="fd3c3665-1729-4b7b-9a38-238e83b0f98b", + ) + + response = client.clusters.begin_extend_software_assurance_benefit( + resource_group_name="test-rg", + cluster_name="myCluster", + software_assurance_change_request={"properties": {"softwareAssuranceIntent": "Enable"}}, + ).result() + print(response) + + +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/ExtendSoftwareAssuranceBenefit.json +if __name__ == "__main__": + main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/extensions_upgrade.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/extensions_upgrade.py new file mode 100644 index 000000000000..a0d610c5d2e3 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/extensions_upgrade.py @@ -0,0 +1,44 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.azurestackhci import AzureStackHCIClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-azurestackhci +# USAGE + python extensions_upgrade.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AzureStackHCIClient( + credential=DefaultAzureCredential(), + subscription_id="fd3c3665-1729-4b7b-9a38-238e83b0f98b", + ) + + client.extensions.begin_upgrade( + resource_group_name="test-rg", + cluster_name="myCluster", + arc_setting_name="default", + extension_name="MicrosoftMonitoringAgent", + extension_upgrade_parameters={"targetVersion": "1.0.18062.0"}, + ).result() + + +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/Extensions_Upgrade.json +if __name__ == "__main__": + main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/generate_password.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/generate_password.py new file mode 100644 index 000000000000..b4cee4ceb668 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/generate_password.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.azurestackhci import AzureStackHCIClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-azurestackhci +# USAGE + python generate_password.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AzureStackHCIClient( + credential=DefaultAzureCredential(), + subscription_id="fd3c3665-1729-4b7b-9a38-238e83b0f98b", + ) + + response = client.arc_settings.generate_password( + resource_group_name="test-rg", + cluster_name="myCluster", + arc_setting_name="default", + ) + print(response) + + +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/GeneratePassword.json +if __name__ == "__main__": + main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_arc_setting.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_arc_setting.py new file mode 100644 index 000000000000..347a55d64f1b --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_arc_setting.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.azurestackhci import AzureStackHCIClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-azurestackhci +# USAGE + python get_arc_setting.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AzureStackHCIClient( + credential=DefaultAzureCredential(), + subscription_id="fd3c3665-1729-4b7b-9a38-238e83b0f98b", + ) + + response = client.arc_settings.get( + resource_group_name="test-rg", + cluster_name="myCluster", + arc_setting_name="default", + ) + print(response) + + +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/GetArcSetting.json +if __name__ == "__main__": + main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_cluster.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_cluster.py new file mode 100644 index 000000000000..bb76d19edeba --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_cluster.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.azurestackhci import AzureStackHCIClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-azurestackhci +# USAGE + python get_cluster.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AzureStackHCIClient( + credential=DefaultAzureCredential(), + subscription_id="fd3c3665-1729-4b7b-9a38-238e83b0f98b", + ) + + response = client.clusters.get( + resource_group_name="test-rg", + cluster_name="myCluster", + ) + print(response) + + +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/GetCluster.json +if __name__ == "__main__": + main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_deployment_settings.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_deployment_settings.py new file mode 100644 index 000000000000..a782f4f04249 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_deployment_settings.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.azurestackhci import AzureStackHCIClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-azurestackhci +# USAGE + python get_deployment_settings.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AzureStackHCIClient( + credential=DefaultAzureCredential(), + subscription_id="fd3c3665-1729-4b7b-9a38-238e83b0f98b", + ) + + response = client.deployment_settings.get( + resource_group_name="test-rg", + cluster_name="myCluster", + ) + print(response) + + +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/GetDeploymentSettings.json +if __name__ == "__main__": + main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_edge_devices.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_edge_devices.py new file mode 100644 index 000000000000..eb5379284d88 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_edge_devices.py @@ -0,0 +1,41 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.azurestackhci import AzureStackHCIClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-azurestackhci +# USAGE + python get_edge_devices.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AzureStackHCIClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.edge_devices.get( + resource_uri="subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/ArcInstance-rg/providers/Microsoft.HybridCompute/machines/Node-1", + ) + print(response) + + +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/GetEdgeDevices.json +if __name__ == "__main__": + main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_extension.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_extension.py new file mode 100644 index 000000000000..26964b55318f --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_extension.py @@ -0,0 +1,44 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.azurestackhci import AzureStackHCIClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-azurestackhci +# USAGE + python get_extension.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AzureStackHCIClient( + credential=DefaultAzureCredential(), + subscription_id="fd3c3665-1729-4b7b-9a38-238e83b0f98b", + ) + + response = client.extensions.get( + resource_group_name="test-rg", + cluster_name="myCluster", + arc_setting_name="default", + extension_name="MicrosoftMonitoringAgent", + ) + print(response) + + +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/GetExtension.json +if __name__ == "__main__": + main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_gallery_image.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_gallery_image.py index 8fa5c2f03ca9..a589bca460c1 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_gallery_image.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_gallery_image.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.azurestackhci import AzureStackHCIClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/preview/2023-09-01-preview/examples/GetGalleryImage.json +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/GetGalleryImage.json if __name__ == "__main__": main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_guest_agent.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_guest_agent.py index 5140554362ec..a07c68186ef2 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_guest_agent.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_guest_agent.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.azurestackhci import AzureStackHCIClient """ @@ -35,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/preview/2023-09-01-preview/examples/GetGuestAgent.json +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/GetGuestAgent.json if __name__ == "__main__": main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_hybrid_identity_metadata.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_hybrid_identity_metadata.py index 13e0d483da8b..041c67a0d416 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_hybrid_identity_metadata.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_hybrid_identity_metadata.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.azurestackhci import AzureStackHCIClient """ @@ -35,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/preview/2023-09-01-preview/examples/GetHybridIdentityMetadata.json +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/GetHybridIdentityMetadata.json if __name__ == "__main__": main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_logical_network.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_logical_network.py index 06be130fcc82..9a27270d8801 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_logical_network.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_logical_network.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.azurestackhci import AzureStackHCIClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/preview/2023-09-01-preview/examples/GetLogicalNetwork.json +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/GetLogicalNetwork.json if __name__ == "__main__": main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_marketplace_gallery_image.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_marketplace_gallery_image.py index 1e3e5fff4824..b9f1742c1d75 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_marketplace_gallery_image.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_marketplace_gallery_image.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.azurestackhci import AzureStackHCIClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/preview/2023-09-01-preview/examples/GetMarketplaceGalleryImage.json +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/GetMarketplaceGalleryImage.json if __name__ == "__main__": main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_network_interface.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_network_interface.py index e45c1ec34bd8..4160b7a00afe 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_network_interface.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_network_interface.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.azurestackhci import AzureStackHCIClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/preview/2023-09-01-preview/examples/GetNetworkInterface.json +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/GetNetworkInterface.json if __name__ == "__main__": main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_offer.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_offer.py new file mode 100644 index 000000000000..02a1e6d7d3c9 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_offer.py @@ -0,0 +1,44 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.azurestackhci import AzureStackHCIClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-azurestackhci +# USAGE + python get_offer.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AzureStackHCIClient( + credential=DefaultAzureCredential(), + subscription_id="fd3c3665-1729-4b7b-9a38-238e83b0f98b", + ) + + response = client.offers.get( + resource_group_name="test-rg", + cluster_name="myCluster", + publisher_name="publisher1", + offer_name="offer1", + ) + print(response) + + +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/GetOffer.json +if __name__ == "__main__": + main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_publisher.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_publisher.py new file mode 100644 index 000000000000..29a62ac85d60 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_publisher.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.azurestackhci import AzureStackHCIClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-azurestackhci +# USAGE + python get_publisher.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AzureStackHCIClient( + credential=DefaultAzureCredential(), + subscription_id="fd3c3665-1729-4b7b-9a38-238e83b0f98b", + ) + + response = client.publishers.get( + resource_group_name="test-rg", + cluster_name="myCluster", + publisher_name="publisher1", + ) + print(response) + + +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/GetPublisher.json +if __name__ == "__main__": + main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_security_settings.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_security_settings.py new file mode 100644 index 000000000000..89600fba6683 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_security_settings.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.azurestackhci import AzureStackHCIClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-azurestackhci +# USAGE + python get_security_settings.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AzureStackHCIClient( + credential=DefaultAzureCredential(), + subscription_id="fd3c3665-1729-4b7b-9a38-238e83b0f98b", + ) + + response = client.security_settings.get( + resource_group_name="test-rg", + cluster_name="myCluster", + ) + print(response) + + +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/GetSecuritySettings.json +if __name__ == "__main__": + main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_sku.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_sku.py new file mode 100644 index 000000000000..dad7547450ae --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_sku.py @@ -0,0 +1,45 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.azurestackhci import AzureStackHCIClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-azurestackhci +# USAGE + python get_sku.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AzureStackHCIClient( + credential=DefaultAzureCredential(), + subscription_id="fd3c3665-1729-4b7b-9a38-238e83b0f98b", + ) + + response = client.skus.get( + resource_group_name="test-rg", + cluster_name="myCluster", + publisher_name="publisher1", + offer_name="offer1", + sku_name="sku1", + ) + print(response) + + +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/GetSku.json +if __name__ == "__main__": + main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_storage_container.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_storage_container.py index 1a3e4cd41d09..14ff90a1860c 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_storage_container.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_storage_container.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.azurestackhci import AzureStackHCIClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/preview/2023-09-01-preview/examples/GetStorageContainer.json +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/GetStorageContainer.json if __name__ == "__main__": main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_update_runs.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_update_runs.py new file mode 100644 index 000000000000..d6401058364e --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_update_runs.py @@ -0,0 +1,44 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.azurestackhci import AzureStackHCIClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-azurestackhci +# USAGE + python get_update_runs.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AzureStackHCIClient( + credential=DefaultAzureCredential(), + subscription_id="b8d594e5-51f3-4c11-9c54-a7771b81c712", + ) + + response = client.update_runs.get( + resource_group_name="testrg", + cluster_name="testcluster", + update_name="Microsoft4.2203.2.32", + update_run_name="23b779ba-0d52-4a80-8571-45ca74664ec3", + ) + print(response) + + +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/GetUpdateRuns.json +if __name__ == "__main__": + main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_update_summaries.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_update_summaries.py new file mode 100644 index 000000000000..f6e223bb938d --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_update_summaries.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.azurestackhci import AzureStackHCIClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-azurestackhci +# USAGE + python get_update_summaries.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AzureStackHCIClient( + credential=DefaultAzureCredential(), + subscription_id="b8d594e5-51f3-4c11-9c54-a7771b81c712", + ) + + response = client.update_summaries.get( + resource_group_name="testrg", + cluster_name="testcluster", + ) + print(response) + + +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/GetUpdateSummaries.json +if __name__ == "__main__": + main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_updates.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_updates.py new file mode 100644 index 000000000000..1be25d46dfe7 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_updates.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.azurestackhci import AzureStackHCIClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-azurestackhci +# USAGE + python get_updates.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AzureStackHCIClient( + credential=DefaultAzureCredential(), + subscription_id="b8d594e5-51f3-4c11-9c54-a7771b81c712", + ) + + response = client.updates.get( + resource_group_name="testrg", + cluster_name="testcluster", + update_name="Microsoft4.2203.2.32", + ) + print(response) + + +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/GetUpdates.json +if __name__ == "__main__": + main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_virtual_hard_disk.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_virtual_hard_disk.py index b2cf4086ef99..4eb4fd5788b9 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_virtual_hard_disk.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_virtual_hard_disk.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.azurestackhci import AzureStackHCIClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/preview/2023-09-01-preview/examples/GetVirtualHardDisk.json +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/GetVirtualHardDisk.json if __name__ == "__main__": main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_virtual_machine_instance.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_virtual_machine_instance.py index 7005c2fe3cb1..59f6788832d2 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_virtual_machine_instance.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/get_virtual_machine_instance.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.azurestackhci import AzureStackHCIClient """ @@ -35,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/preview/2023-09-01-preview/examples/GetVirtualMachineInstance.json +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/GetVirtualMachineInstance.json if __name__ == "__main__": main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/guest_agent_list.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/guest_agent_list.py index 258f6c7a9c4c..2f324979fe23 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/guest_agent_list.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/guest_agent_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.azurestackhci import AzureStackHCIClient """ @@ -36,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/preview/2023-09-01-preview/examples/GuestAgent_List.json +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/GuestAgent_List.json if __name__ == "__main__": main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/hybrid_identity_metadata_list.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/hybrid_identity_metadata_list.py index 307c12f8733d..5e0fd98267ac 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/hybrid_identity_metadata_list.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/hybrid_identity_metadata_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.azurestackhci import AzureStackHCIClient """ @@ -36,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/preview/2023-09-01-preview/examples/HybridIdentityMetadata_List.json +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/HybridIdentityMetadata_List.json if __name__ == "__main__": main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/initialize_disable_process.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/initialize_disable_process.py new file mode 100644 index 000000000000..8c8b1fd2e5a9 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/initialize_disable_process.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.azurestackhci import AzureStackHCIClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-azurestackhci +# USAGE + python initialize_disable_process.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AzureStackHCIClient( + credential=DefaultAzureCredential(), + subscription_id="fd3c3665-1729-4b7b-9a38-238e83b0f98b", + ) + + client.arc_settings.begin_initialize_disable_process( + resource_group_name="test-rg", + cluster_name="myCluster", + arc_setting_name="default", + ).result() + + +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/InitializeDisableProcess.json +if __name__ == "__main__": + main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_arc_settings_by_cluster.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_arc_settings_by_cluster.py new file mode 100644 index 000000000000..3a5b5344f63e --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_arc_settings_by_cluster.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.azurestackhci import AzureStackHCIClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-azurestackhci +# USAGE + python list_arc_settings_by_cluster.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AzureStackHCIClient( + credential=DefaultAzureCredential(), + subscription_id="fd3c3665-1729-4b7b-9a38-238e83b0f98b", + ) + + response = client.arc_settings.list_by_cluster( + resource_group_name="test-rg", + cluster_name="myCluster", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/ListArcSettingsByCluster.json +if __name__ == "__main__": + main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_clusters_by_resource_group.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_clusters_by_resource_group.py new file mode 100644 index 000000000000..7447b6ccb467 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_clusters_by_resource_group.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.azurestackhci import AzureStackHCIClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-azurestackhci +# USAGE + python list_clusters_by_resource_group.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AzureStackHCIClient( + credential=DefaultAzureCredential(), + subscription_id="fd3c3665-1729-4b7b-9a38-238e83b0f98b", + ) + + response = client.clusters.list_by_resource_group( + resource_group_name="test-rg", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/ListClustersByResourceGroup.json +if __name__ == "__main__": + main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_clusters_by_subscription.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_clusters_by_subscription.py new file mode 100644 index 000000000000..ecb42c758efb --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_clusters_by_subscription.py @@ -0,0 +1,40 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.azurestackhci import AzureStackHCIClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-azurestackhci +# USAGE + python list_clusters_by_subscription.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AzureStackHCIClient( + credential=DefaultAzureCredential(), + subscription_id="fd3c3665-1729-4b7b-9a38-238e83b0f98b", + ) + + response = client.clusters.list_by_subscription() + for item in response: + print(item) + + +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/ListClustersBySubscription.json +if __name__ == "__main__": + main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_deployment_settings_by_cluster.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_deployment_settings_by_cluster.py new file mode 100644 index 000000000000..c9ab35756135 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_deployment_settings_by_cluster.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.azurestackhci import AzureStackHCIClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-azurestackhci +# USAGE + python list_deployment_settings_by_cluster.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AzureStackHCIClient( + credential=DefaultAzureCredential(), + subscription_id="fd3c3665-1729-4b7b-9a38-238e83b0f98b", + ) + + response = client.deployment_settings.list_by_clusters( + resource_group_name="test-rg", + cluster_name="myCluster", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/ListDeploymentSettingsByCluster.json +if __name__ == "__main__": + main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_edge_devices.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_edge_devices.py new file mode 100644 index 000000000000..28b9d72a6ead --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_edge_devices.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.azurestackhci import AzureStackHCIClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-azurestackhci +# USAGE + python list_edge_devices.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AzureStackHCIClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.edge_devices.list( + resource_uri="subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/ArcInstance-rg/providers/Microsoft.HybridCompute/machines/Node-1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/ListEdgeDevices.json +if __name__ == "__main__": + main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_extensions_by_arc_setting.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_extensions_by_arc_setting.py new file mode 100644 index 000000000000..193ce281e358 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_extensions_by_arc_setting.py @@ -0,0 +1,44 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.azurestackhci import AzureStackHCIClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-azurestackhci +# USAGE + python list_extensions_by_arc_setting.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AzureStackHCIClient( + credential=DefaultAzureCredential(), + subscription_id="fd3c3665-1729-4b7b-9a38-238e83b0f98b", + ) + + response = client.extensions.list_by_arc_setting( + resource_group_name="test-rg", + cluster_name="myCluster", + arc_setting_name="default", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/ListExtensionsByArcSetting.json +if __name__ == "__main__": + main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_gallery_image_by_resource_group.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_gallery_image_by_resource_group.py index 9135cbddd88c..9cbc4d06a699 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_gallery_image_by_resource_group.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_gallery_image_by_resource_group.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.azurestackhci import AzureStackHCIClient """ @@ -36,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/preview/2023-09-01-preview/examples/ListGalleryImageByResourceGroup.json +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/ListGalleryImageByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_gallery_image_by_subscription.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_gallery_image_by_subscription.py index cb8daa8fcdd1..034f0912d63f 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_gallery_image_by_subscription.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_gallery_image_by_subscription.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.azurestackhci import AzureStackHCIClient """ @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/preview/2023-09-01-preview/examples/ListGalleryImageBySubscription.json +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/ListGalleryImageBySubscription.json if __name__ == "__main__": main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_logical_network_by_resource_group.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_logical_network_by_resource_group.py index 2e9f3f35bd4c..4786ef948351 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_logical_network_by_resource_group.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_logical_network_by_resource_group.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.azurestackhci import AzureStackHCIClient """ @@ -36,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/preview/2023-09-01-preview/examples/ListLogicalNetworkByResourceGroup.json +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/ListLogicalNetworkByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_logical_network_by_subscription.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_logical_network_by_subscription.py index 904fc13479fa..c226b7cd87a1 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_logical_network_by_subscription.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_logical_network_by_subscription.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.azurestackhci import AzureStackHCIClient """ @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/preview/2023-09-01-preview/examples/ListLogicalNetworkBySubscription.json +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/ListLogicalNetworkBySubscription.json if __name__ == "__main__": main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_marketplace_gallery_image_by_resource_group.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_marketplace_gallery_image_by_resource_group.py index 09e304ce94d4..79b4403b9e6a 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_marketplace_gallery_image_by_resource_group.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_marketplace_gallery_image_by_resource_group.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.azurestackhci import AzureStackHCIClient """ @@ -36,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/preview/2023-09-01-preview/examples/ListMarketplaceGalleryImageByResourceGroup.json +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/ListMarketplaceGalleryImageByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_marketplace_gallery_image_by_subscription.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_marketplace_gallery_image_by_subscription.py index 8f154b3b65c6..02ef33a425de 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_marketplace_gallery_image_by_subscription.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_marketplace_gallery_image_by_subscription.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.azurestackhci import AzureStackHCIClient """ @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/preview/2023-09-01-preview/examples/ListMarketplaceGalleryImageBySubscription.json +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/ListMarketplaceGalleryImageBySubscription.json if __name__ == "__main__": main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_network_interface_by_resource_group.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_network_interface_by_resource_group.py index 9a2c211b0986..ec546f1d616f 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_network_interface_by_resource_group.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_network_interface_by_resource_group.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.azurestackhci import AzureStackHCIClient """ @@ -36,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/preview/2023-09-01-preview/examples/ListNetworkInterfaceByResourceGroup.json +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/ListNetworkInterfaceByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_network_interface_by_subscription.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_network_interface_by_subscription.py index b3911edc0c88..d3aade7760c0 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_network_interface_by_subscription.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_network_interface_by_subscription.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.azurestackhci import AzureStackHCIClient """ @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/preview/2023-09-01-preview/examples/ListNetworkInterfaceBySubscription.json +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/ListNetworkInterfaceBySubscription.json if __name__ == "__main__": main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_offers_by_cluster.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_offers_by_cluster.py new file mode 100644 index 000000000000..eba2f4a37963 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_offers_by_cluster.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.azurestackhci import AzureStackHCIClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-azurestackhci +# USAGE + python list_offers_by_cluster.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AzureStackHCIClient( + credential=DefaultAzureCredential(), + subscription_id="fd3c3665-1729-4b7b-9a38-238e83b0f98b", + ) + + response = client.offers.list_by_cluster( + resource_group_name="test-rg", + cluster_name="myCluster", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/ListOffersByCluster.json +if __name__ == "__main__": + main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_offers_by_publisher.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_offers_by_publisher.py new file mode 100644 index 000000000000..225e652e19d3 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_offers_by_publisher.py @@ -0,0 +1,44 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.azurestackhci import AzureStackHCIClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-azurestackhci +# USAGE + python list_offers_by_publisher.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AzureStackHCIClient( + credential=DefaultAzureCredential(), + subscription_id="fd3c3665-1729-4b7b-9a38-238e83b0f98b", + ) + + response = client.offers.list_by_publisher( + resource_group_name="test-rg", + cluster_name="myCluster", + publisher_name="publisher1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/ListOffersByPublisher.json +if __name__ == "__main__": + main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_operations.py index b8009c30c955..394a76d00cc9 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_operations.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_operations.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.azurestackhci import AzureStackHCIClient """ @@ -30,10 +31,9 @@ def main(): ) response = client.operations.list() - for item in response: - print(item) + print(response) -# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/preview/2023-09-01-preview/examples/ListOperations.json +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/ListOperations.json if __name__ == "__main__": main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_publishers_by_cluster.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_publishers_by_cluster.py new file mode 100644 index 000000000000..ff52fd15b7c7 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_publishers_by_cluster.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.azurestackhci import AzureStackHCIClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-azurestackhci +# USAGE + python list_publishers_by_cluster.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AzureStackHCIClient( + credential=DefaultAzureCredential(), + subscription_id="fd3c3665-1729-4b7b-9a38-238e83b0f98b", + ) + + response = client.publishers.list_by_cluster( + resource_group_name="test-rg", + cluster_name="myCluster", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/ListPublishersByCluster.json +if __name__ == "__main__": + main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_security_settings_by_cluster.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_security_settings_by_cluster.py new file mode 100644 index 000000000000..d50d02b053ff --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_security_settings_by_cluster.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.azurestackhci import AzureStackHCIClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-azurestackhci +# USAGE + python list_security_settings_by_cluster.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AzureStackHCIClient( + credential=DefaultAzureCredential(), + subscription_id="fd3c3665-1729-4b7b-9a38-238e83b0f98b", + ) + + response = client.security_settings.list_by_clusters( + resource_group_name="test-rg", + cluster_name="myCluster", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/ListSecuritySettingsByCluster.json +if __name__ == "__main__": + main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_skus_by_offer.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_skus_by_offer.py new file mode 100644 index 000000000000..adf1fb1bf268 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_skus_by_offer.py @@ -0,0 +1,45 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.azurestackhci import AzureStackHCIClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-azurestackhci +# USAGE + python list_skus_by_offer.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AzureStackHCIClient( + credential=DefaultAzureCredential(), + subscription_id="fd3c3665-1729-4b7b-9a38-238e83b0f98b", + ) + + response = client.skus.list_by_offer( + resource_group_name="test-rg", + cluster_name="myCluster", + publisher_name="publisher1", + offer_name="offer1", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/ListSkusByOffer.json +if __name__ == "__main__": + main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_storage_container_by_resource_group.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_storage_container_by_resource_group.py index a2ee5f565953..3abada8c42ae 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_storage_container_by_resource_group.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_storage_container_by_resource_group.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.azurestackhci import AzureStackHCIClient """ @@ -36,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/preview/2023-09-01-preview/examples/ListStorageContainerByResourceGroup.json +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/ListStorageContainerByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_storage_container_by_subscription.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_storage_container_by_subscription.py index 3d9d62694db8..b6e289f57420 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_storage_container_by_subscription.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_storage_container_by_subscription.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.azurestackhci import AzureStackHCIClient """ @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/preview/2023-09-01-preview/examples/ListStorageContainerBySubscription.json +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/ListStorageContainerBySubscription.json if __name__ == "__main__": main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_update_runs.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_update_runs.py new file mode 100644 index 000000000000..65a9d180fb6c --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_update_runs.py @@ -0,0 +1,44 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.azurestackhci import AzureStackHCIClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-azurestackhci +# USAGE + python list_update_runs.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AzureStackHCIClient( + credential=DefaultAzureCredential(), + subscription_id="b8d594e5-51f3-4c11-9c54-a7771b81c712", + ) + + response = client.update_runs.list( + resource_group_name="testrg", + cluster_name="testcluster", + update_name="Microsoft4.2203.2.32", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/ListUpdateRuns.json +if __name__ == "__main__": + main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_update_summaries.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_update_summaries.py new file mode 100644 index 000000000000..f8c0a323d922 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_update_summaries.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.azurestackhci import AzureStackHCIClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-azurestackhci +# USAGE + python list_update_summaries.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AzureStackHCIClient( + credential=DefaultAzureCredential(), + subscription_id="b8d594e5-51f3-4c11-9c54-a7771b81c712", + ) + + response = client.update_summaries.list( + resource_group_name="testrg", + cluster_name="testcluster", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/ListUpdateSummaries.json +if __name__ == "__main__": + main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_updates.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_updates.py new file mode 100644 index 000000000000..d068673345ad --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_updates.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.azurestackhci import AzureStackHCIClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-azurestackhci +# USAGE + python list_updates.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AzureStackHCIClient( + credential=DefaultAzureCredential(), + subscription_id="b8d594e5-51f3-4c11-9c54-a7771b81c712", + ) + + response = client.updates.list( + resource_group_name="testrg", + cluster_name="testcluster", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/ListUpdates.json +if __name__ == "__main__": + main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_virtual_hard_disk_by_resource_group.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_virtual_hard_disk_by_resource_group.py index c86a4be57ae1..2c250c1e9a86 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_virtual_hard_disk_by_resource_group.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_virtual_hard_disk_by_resource_group.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.azurestackhci import AzureStackHCIClient """ @@ -36,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/preview/2023-09-01-preview/examples/ListVirtualHardDiskByResourceGroup.json +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/ListVirtualHardDiskByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_virtual_hard_disk_by_subscription.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_virtual_hard_disk_by_subscription.py index aaad47a7b2ca..6627bf0b440d 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_virtual_hard_disk_by_subscription.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_virtual_hard_disk_by_subscription.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.azurestackhci import AzureStackHCIClient """ @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/preview/2023-09-01-preview/examples/ListVirtualHardDiskBySubscription.json +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/ListVirtualHardDiskBySubscription.json if __name__ == "__main__": main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_virtual_machine_instances.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_virtual_machine_instances.py index 82076a20cadd..83df992e5f2c 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_virtual_machine_instances.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/list_virtual_machine_instances.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.azurestackhci import AzureStackHCIClient """ @@ -36,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/preview/2023-09-01-preview/examples/ListVirtualMachineInstances.json +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/ListVirtualMachineInstances.json if __name__ == "__main__": main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/patch_arc_setting.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/patch_arc_setting.py new file mode 100644 index 000000000000..7c66a70d0709 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/patch_arc_setting.py @@ -0,0 +1,51 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.azurestackhci import AzureStackHCIClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-azurestackhci +# USAGE + python patch_arc_setting.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AzureStackHCIClient( + credential=DefaultAzureCredential(), + subscription_id="fd3c3665-1729-4b7b-9a38-238e83b0f98b", + ) + + response = client.arc_settings.update( + resource_group_name="test-rg", + cluster_name="myCluster", + arc_setting_name="default", + arc_setting={ + "properties": { + "connectivityProperties": { + "enabled": True, + "serviceConfigurations": [{"port": 6516, "serviceName": "WAC"}], + } + } + }, + ) + print(response) + + +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/PatchArcSetting.json +if __name__ == "__main__": + main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/patch_extension.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/patch_extension.py new file mode 100644 index 000000000000..9dde3aae3ea0 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/patch_extension.py @@ -0,0 +1,54 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.azurestackhci import AzureStackHCIClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-azurestackhci +# USAGE + python patch_extension.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AzureStackHCIClient( + credential=DefaultAzureCredential(), + subscription_id="fd3c3665-1729-4b7b-9a38-238e83b0f98b", + ) + + response = client.extensions.begin_update( + resource_group_name="test-rg", + cluster_name="myCluster", + arc_setting_name="default", + extension_name="MicrosoftMonitoringAgent", + extension={ + "properties": { + "extensionParameters": { + "enableAutomaticUpgrade": False, + "protectedSettings": {"workspaceKey": "xx"}, + "settings": {"workspaceId": "xx"}, + "typeHandlerVersion": "1.10", + } + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/PatchExtension.json +if __name__ == "__main__": + main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/post_updates.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/post_updates.py new file mode 100644 index 000000000000..8727fc588706 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/post_updates.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.azurestackhci import AzureStackHCIClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-azurestackhci +# USAGE + python post_updates.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AzureStackHCIClient( + credential=DefaultAzureCredential(), + subscription_id="b8d594e5-51f3-4c11-9c54-a7771b81c712", + ) + + client.updates.begin_post( + resource_group_name="testrg", + cluster_name="testcluster", + update_name="Microsoft4.2203.2.32", + ).result() + + +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/PostUpdates.json +if __name__ == "__main__": + main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_deployment_settings.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_deployment_settings.py new file mode 100644 index 000000000000..dd49fd1fa0af --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_deployment_settings.py @@ -0,0 +1,132 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.azurestackhci import AzureStackHCIClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-azurestackhci +# USAGE + python put_deployment_settings.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AzureStackHCIClient( + credential=DefaultAzureCredential(), + subscription_id="fd3c3665-1729-4b7b-9a38-238e83b0f98b", + ) + + response = client.deployment_settings.begin_create_or_update( + resource_group_name="test-rg", + cluster_name="myCluster", + resource={ + "properties": { + "arcNodeResourceIds": [ + "/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/ArcInstance-rg/providers/Microsoft.HybridCompute/machines/Node-1", + "/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/ArcInstance-rg/providers/Microsoft.HybridCompute/machines/Node-2", + ], + "deploymentConfiguration": { + "scaleUnits": [ + { + "deploymentData": { + "adouPath": "OU=ms169,DC=ASZ1PLab8,DC=nttest,DC=microsoft,DC=com", + "cluster": { + "azureServiceEndpoint": "core.windows.net", + "cloudAccountName": "myasestoragacct", + "name": "testHCICluster", + "witnessPath": "Cloud", + "witnessType": "Cloud", + }, + "domainFqdn": "ASZ1PLab8.nttest.microsoft.com", + "hostNetwork": { + "intents": [ + { + "adapter": ["Port2"], + "adapterPropertyOverrides": { + "jumboPacket": "1514", + "networkDirect": "Enabled", + "networkDirectTechnology": "iWARP", + }, + "name": "Compute_Management", + "overrideAdapterProperty": False, + "overrideQosPolicy": False, + "overrideVirtualSwitchConfiguration": False, + "qosPolicyOverrides": { + "bandwidthPercentage_SMB": "50", + "priorityValue8021Action_Cluster": "7", + "priorityValue8021Action_SMB": "3", + }, + "trafficType": ["Compute", "Management"], + "virtualSwitchConfigurationOverrides": { + "enableIov": "True", + "loadBalancingAlgorithm": "HyperVPort", + }, + } + ], + "storageConnectivitySwitchless": True, + "storageNetworks": [ + {"name": "Storage1Network", "networkAdapterName": "Port3", "vlanId": "5"} + ], + }, + "infrastructureNetwork": [ + { + "dnsServers": ["10.57.50.90"], + "gateway": "255.255.248.0", + "ipPools": [{"endingAddress": "10.57.48.66", "startingAddress": "10.57.48.60"}], + "subnetMask": "255.255.248.0", + } + ], + "namingPrefix": "ms169", + "observability": { + "episodicDataUpload": True, + "euLocation": False, + "streamingDataClient": True, + }, + "optionalServices": {"customLocation": "customLocationName"}, + "physicalNodes": [ + {"ipv4Address": "10.57.51.224", "name": "ms169host"}, + {"ipv4Address": "10.57.53.236", "name": "ms154host"}, + ], + "secretsLocation": "/subscriptions/db4e2fdb-6d80-4e6e-b7cd-xxxxxxx/resourceGroups/test-rg/providers/Microsoft.KeyVault/vaults/abcd123", + "securitySettings": { + "bitlockerBootVolume": True, + "bitlockerDataVolumes": True, + "credentialGuardEnforced": False, + "driftControlEnforced": True, + "drtmProtection": True, + "hvciProtection": True, + "sideChannelMitigationEnforced": True, + "smbClusterEncryption": False, + "smbSigningEnforced": True, + "wdacEnforced": True, + }, + "storage": {"configurationMode": "Express"}, + } + } + ], + "version": "string", + }, + "deploymentMode": "Deploy", + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/PutDeploymentSettings.json +if __name__ == "__main__": + main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_edge_devices.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_edge_devices.py new file mode 100644 index 000000000000..297b163aff85 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_edge_devices.py @@ -0,0 +1,61 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.azurestackhci import AzureStackHCIClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-azurestackhci +# USAGE + python put_edge_devices.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AzureStackHCIClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.edge_devices.begin_create_or_update( + resource_uri="subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/ArcInstance-rg/providers/Microsoft.HybridCompute/machines/Node-1", + resource={ + "properties": { + "deviceConfiguration": { + "deviceMetadata": "", + "nicDetails": [ + { + "adapterName": "ethernet", + "componentId": "VMBUS{f8615163-df3e-46c5-913f-f2d2f965ed0g} ", + "defaultGateway": "10.10.10.1", + "defaultIsolationId": "0", + "dnsServers": ["100.10.10.1"], + "driverVersion": "10.0.20348.1547 ", + "interfaceDescription": "NDIS 6.70 ", + "ip4Address": "10.10.10.10", + "subnetMask": "255.255.255.0", + } + ], + } + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/PutEdgeDevices.json +if __name__ == "__main__": + main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_extension.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_extension.py new file mode 100644 index 000000000000..cb3beba6fdbd --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_extension.py @@ -0,0 +1,56 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.azurestackhci import AzureStackHCIClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-azurestackhci +# USAGE + python put_extension.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AzureStackHCIClient( + credential=DefaultAzureCredential(), + subscription_id="fd3c3665-1729-4b7b-9a38-238e83b0f98b", + ) + + response = client.extensions.begin_create( + resource_group_name="test-rg", + cluster_name="myCluster", + arc_setting_name="default", + extension_name="MicrosoftMonitoringAgent", + extension={ + "properties": { + "extensionParameters": { + "enableAutomaticUpgrade": False, + "protectedSettings": {"workspaceKey": "xx"}, + "publisher": "Microsoft.Compute", + "settings": {"workspaceId": "xx"}, + "type": "MicrosoftMonitoringAgent", + "typeHandlerVersion": "1.10", + } + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/PutExtension.json +if __name__ == "__main__": + main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_gallery_image.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_gallery_image.py index ae5132ae77ac..fe59faa1cd16 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_gallery_image.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_gallery_image.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.azurestackhci import AzureStackHCIClient """ @@ -48,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/preview/2023-09-01-preview/examples/PutGalleryImage.json +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/PutGalleryImage.json if __name__ == "__main__": main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_logical_network.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_logical_network.py index 76bd3b22bd30..c29dac48f808 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_logical_network.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_logical_network.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.azurestackhci import AzureStackHCIClient """ @@ -43,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/preview/2023-09-01-preview/examples/PutLogicalNetwork.json +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/PutLogicalNetwork.json if __name__ == "__main__": main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_marketplace_gallery_image.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_marketplace_gallery_image.py index 524234606d4e..3f1abcec9ce0 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_marketplace_gallery_image.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_marketplace_gallery_image.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.azurestackhci import AzureStackHCIClient """ @@ -51,6 +52,6 @@ def main(): print(response) -# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/preview/2023-09-01-preview/examples/PutMarketplaceGalleryImage.json +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/PutMarketplaceGalleryImage.json if __name__ == "__main__": main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_network_interface.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_network_interface.py index d32366e8019a..6730aa60bcde 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_network_interface.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_network_interface.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.azurestackhci import AzureStackHCIClient """ @@ -46,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/preview/2023-09-01-preview/examples/PutNetworkInterface.json +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/PutNetworkInterface.json if __name__ == "__main__": main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_security_settings.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_security_settings.py new file mode 100644 index 000000000000..6bf4edff2a9a --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_security_settings.py @@ -0,0 +1,43 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.azurestackhci import AzureStackHCIClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-azurestackhci +# USAGE + python put_security_settings.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AzureStackHCIClient( + credential=DefaultAzureCredential(), + subscription_id="fd3c3665-1729-4b7b-9a38-238e83b0f98b", + ) + + response = client.security_settings.begin_create_or_update( + resource_group_name="test-rg", + cluster_name="myCluster", + resource={"properties": {"securedCoreComplianceAssignment": "Audit"}}, + ).result() + print(response) + + +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/PutSecuritySettings.json +if __name__ == "__main__": + main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_storage_container.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_storage_container.py index f8eb72acae84..f7cdaa1ddc7c 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_storage_container.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_storage_container.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.azurestackhci import AzureStackHCIClient """ @@ -44,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/preview/2023-09-01-preview/examples/PutStorageContainer.json +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/PutStorageContainer.json if __name__ == "__main__": main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_update_runs.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_update_runs.py new file mode 100644 index 000000000000..4bcb151c99ca --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_update_runs.py @@ -0,0 +1,69 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.azurestackhci import AzureStackHCIClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-azurestackhci +# USAGE + python put_update_runs.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AzureStackHCIClient( + credential=DefaultAzureCredential(), + subscription_id="b8d594e5-51f3-4c11-9c54-a7771b81c712", + ) + + response = client.update_runs.put( + resource_group_name="testrg", + cluster_name="testcluster", + update_name="Microsoft4.2203.2.32", + update_run_name="23b779ba-0d52-4a80-8571-45ca74664ec3", + update_runs_properties={ + "properties": { + "progress": { + "description": "Update Azure Stack.", + "endTimeUtc": "2022-04-06T13:58:42.969006+00:00", + "errorMessage": "", + "lastUpdatedTimeUtc": "2022-04-06T13:58:42.969006+00:00", + "name": "Unnamed step", + "startTimeUtc": "2022-04-06T01:36:33.3876751+00:00", + "status": "Success", + "steps": [ + { + "description": "Prepare for SSU update", + "endTimeUtc": "2022-04-06T01:37:16.8728314+00:00", + "errorMessage": "", + "lastUpdatedTimeUtc": "2022-04-06T01:37:16.8728314+00:00", + "name": "PreUpdate Cloud", + "startTimeUtc": "2022-04-06T01:36:33.3876751+00:00", + "status": "Success", + "steps": [], + } + ], + } + } + }, + ) + print(response) + + +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/PutUpdateRuns.json +if __name__ == "__main__": + main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_update_summaries.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_update_summaries.py new file mode 100644 index 000000000000..c2fcb253a4a4 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_update_summaries.py @@ -0,0 +1,52 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.azurestackhci import AzureStackHCIClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-azurestackhci +# USAGE + python put_update_summaries.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AzureStackHCIClient( + credential=DefaultAzureCredential(), + subscription_id="b8d594e5-51f3-4c11-9c54-a7771b81c712", + ) + + response = client.update_summaries.put( + resource_group_name="testrg", + cluster_name="testcluster", + update_location_properties={ + "properties": { + "currentVersion": "4.2203.2.32", + "hardwareModel": "PowerEdge R730xd", + "lastChecked": "2022-04-07T18:04:07Z", + "lastUpdated": "2022-04-06T14:08:18.254Z", + "oemFamily": "DellEMC", + "state": "AppliedSuccessfully", + } + }, + ) + print(response) + + +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/PutUpdateSummaries.json +if __name__ == "__main__": + main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_updates.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_updates.py new file mode 100644 index 000000000000..153370f34411 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_updates.py @@ -0,0 +1,70 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.azurestackhci import AzureStackHCIClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-azurestackhci +# USAGE + python put_updates.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AzureStackHCIClient( + credential=DefaultAzureCredential(), + subscription_id="b8d594e5-51f3-4c11-9c54-a7771b81c712", + ) + + response = client.updates.put( + resource_group_name="testrg", + cluster_name="testcluster", + update_name="Microsoft4.2203.2.32", + update_properties={ + "properties": { + "additionalProperties": "additional properties", + "availabilityType": "Local", + "description": "AzS Update 4.2203.2.32", + "displayName": "AzS Update - 4.2203.2.32", + "installedDate": "2022-04-06T14:08:18.254Z", + "packagePath": "\\\\SU1FileServer\\SU1_Infrastructure_2\\Updates\\Packages\\Microsoft4.2203.2.32", + "packageSizeInMb": 18858, + "packageType": "Infrastructure", + "prerequisites": [ + { + "packageName": "update package name", + "updateType": "update type", + "version": "prerequisite version", + } + ], + "publisher": "Microsoft", + "releaseLink": "https://docs.microsoft.com/azure-stack/operator/release-notes?view=azs-2203", + "state": "Installed", + "updateStateProperties": { + "notifyMessage": "Brief message with instructions for updates of AvailabilityType Notify", + "progressPercentage": 0, + }, + "version": "4.2203.2.32", + } + }, + ) + print(response) + + +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/PutUpdates.json +if __name__ == "__main__": + main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_virtual_hard_disk.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_virtual_hard_disk.py index a87a99b5c2f2..5bbb605f2332 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_virtual_hard_disk.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_virtual_hard_disk.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.azurestackhci import AzureStackHCIClient """ @@ -44,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/preview/2023-09-01-preview/examples/PutVirtualHardDisk.json +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/PutVirtualHardDisk.json if __name__ == "__main__": main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_virtual_machine_instance_with_gallery_image.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_virtual_machine_instance_with_gallery_image.py index e2e61c6b1bc1..cee50048854e 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_virtual_machine_instance_with_gallery_image.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_virtual_machine_instance_with_gallery_image.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.azurestackhci import AzureStackHCIClient """ @@ -53,6 +54,6 @@ def main(): print(response) -# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/preview/2023-09-01-preview/examples/PutVirtualMachineInstanceWithGalleryImage.json +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/PutVirtualMachineInstanceWithGalleryImage.json if __name__ == "__main__": main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_virtual_machine_instance_with_marketplace_gallery_image.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_virtual_machine_instance_with_marketplace_gallery_image.py index e3e4570a6f4c..d5704b3d4b97 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_virtual_machine_instance_with_marketplace_gallery_image.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_virtual_machine_instance_with_marketplace_gallery_image.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.azurestackhci import AzureStackHCIClient """ @@ -53,6 +54,6 @@ def main(): print(response) -# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/preview/2023-09-01-preview/examples/PutVirtualMachineInstanceWithMarketplaceGalleryImage.json +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/PutVirtualMachineInstanceWithMarketplaceGalleryImage.json if __name__ == "__main__": main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_virtual_machine_instance_with_os_disk.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_virtual_machine_instance_with_os_disk.py index 1cdccf354faf..7080230c205b 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_virtual_machine_instance_with_os_disk.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_virtual_machine_instance_with_os_disk.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.azurestackhci import AzureStackHCIClient """ @@ -52,6 +53,6 @@ def main(): print(response) -# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/preview/2023-09-01-preview/examples/PutVirtualMachineInstanceWithOsDisk.json +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/PutVirtualMachineInstanceWithOsDisk.json if __name__ == "__main__": main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_virtual_machine_instance_with_vm_config_agent.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_virtual_machine_instance_with_vm_config_agent.py index 07de847600e0..fa145b5df2a1 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_virtual_machine_instance_with_vm_config_agent.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/put_virtual_machine_instance_with_vm_config_agent.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.azurestackhci import AzureStackHCIClient """ @@ -58,6 +59,6 @@ def main(): print(response) -# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/preview/2023-09-01-preview/examples/PutVirtualMachineInstanceWithVMConfigAgent.json +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/PutVirtualMachineInstanceWithVMConfigAgent.json if __name__ == "__main__": main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/restart_virtual_machine_instance.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/restart_virtual_machine_instance.py index 8ac57cc69c78..4b0f2a4262f6 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/restart_virtual_machine_instance.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/restart_virtual_machine_instance.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.azurestackhci import AzureStackHCIClient """ @@ -35,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/preview/2023-09-01-preview/examples/RestartVirtualMachineInstance.json +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/RestartVirtualMachineInstance.json if __name__ == "__main__": main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/start_virtual_machine_instance.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/start_virtual_machine_instance.py index 936d7b728866..c47af23db1e9 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/start_virtual_machine_instance.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/start_virtual_machine_instance.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.azurestackhci import AzureStackHCIClient """ @@ -35,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/preview/2023-09-01-preview/examples/StartVirtualMachineInstance.json +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/StartVirtualMachineInstance.json if __name__ == "__main__": main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/stop_virtual_machine_instance.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/stop_virtual_machine_instance.py index 7877f141e7ad..1682189a8403 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/stop_virtual_machine_instance.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/stop_virtual_machine_instance.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.azurestackhci import AzureStackHCIClient """ @@ -35,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/preview/2023-09-01-preview/examples/StopVirtualMachineInstance.json +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/StopVirtualMachineInstance.json if __name__ == "__main__": main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/update_cluster.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/update_cluster.py new file mode 100644 index 000000000000..1f0a50787086 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/update_cluster.py @@ -0,0 +1,50 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.azurestackhci import AzureStackHCIClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-azurestackhci +# USAGE + python update_cluster.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AzureStackHCIClient( + credential=DefaultAzureCredential(), + subscription_id="fd3c3665-1729-4b7b-9a38-238e83b0f98b", + ) + + response = client.clusters.update( + resource_group_name="test-rg", + cluster_name="myCluster", + cluster={ + "identity": {"type": "SystemAssigned"}, + "properties": { + "cloudManagementEndpoint": "https://98294836-31be-4668-aeae-698667faf99b.waconazure.com", + "desiredProperties": {"diagnosticLevel": "Basic", "windowsServerSubscription": "Enabled"}, + }, + "tags": {"tag1": "value1", "tag2": "value2"}, + }, + ) + print(response) + + +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/UpdateCluster.json +if __name__ == "__main__": + main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/update_gallery_image.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/update_gallery_image.py index 9868ff7cf89d..42168f63c45f 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/update_gallery_image.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/update_gallery_image.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.azurestackhci import AzureStackHCIClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/preview/2023-09-01-preview/examples/UpdateGalleryImage.json +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/UpdateGalleryImage.json if __name__ == "__main__": main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/update_logical_network.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/update_logical_network.py index f8dac8a0a234..98c009cd83d0 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/update_logical_network.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/update_logical_network.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.azurestackhci import AzureStackHCIClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/preview/2023-09-01-preview/examples/UpdateLogicalNetwork.json +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/UpdateLogicalNetwork.json if __name__ == "__main__": main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/update_marketplace_gallery_image.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/update_marketplace_gallery_image.py index 2a6e7c999af7..af5ac02dc054 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/update_marketplace_gallery_image.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/update_marketplace_gallery_image.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.azurestackhci import AzureStackHCIClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/preview/2023-09-01-preview/examples/UpdateMarketplaceGalleryImage.json +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/UpdateMarketplaceGalleryImage.json if __name__ == "__main__": main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/update_network_interface.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/update_network_interface.py index 9b96e6c5e4e0..da73eff2b6cc 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/update_network_interface.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/update_network_interface.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.azurestackhci import AzureStackHCIClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/preview/2023-09-01-preview/examples/UpdateNetworkInterface.json +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/UpdateNetworkInterface.json if __name__ == "__main__": main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/update_storage_container.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/update_storage_container.py index b1d884971ffc..cebfaa10c000 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/update_storage_container.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/update_storage_container.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.azurestackhci import AzureStackHCIClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/preview/2023-09-01-preview/examples/UpdateStorageContainer.json +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/UpdateStorageContainer.json if __name__ == "__main__": main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/update_virtual_hard_disk.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/update_virtual_hard_disk.py index 76f0c632c0e3..fe6d07910acc 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/update_virtual_hard_disk.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/update_virtual_hard_disk.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.azurestackhci import AzureStackHCIClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/preview/2023-09-01-preview/examples/UpdateVirtualHardDisk.json +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/UpdateVirtualHardDisk.json if __name__ == "__main__": main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/update_virtual_machine_instance.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/update_virtual_machine_instance.py index 1516e248cb2f..921fe870fc93 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/update_virtual_machine_instance.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/update_virtual_machine_instance.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.azurestackhci import AzureStackHCIClient """ @@ -46,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/preview/2023-09-01-preview/examples/UpdateVirtualMachineInstance.json +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/UpdateVirtualMachineInstance.json if __name__ == "__main__": main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/upload_certificate.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/upload_certificate.py new file mode 100644 index 000000000000..c7724fafe982 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_samples/upload_certificate.py @@ -0,0 +1,42 @@ +# 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 azure.identity import DefaultAzureCredential + +from azure.mgmt.azurestackhci import AzureStackHCIClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-azurestackhci +# USAGE + python upload_certificate.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = AzureStackHCIClient( + credential=DefaultAzureCredential(), + subscription_id="fd3c3665-1729-4b7b-9a38-238e83b0f98b", + ) + + client.clusters.begin_upload_certificate( + resource_group_name="test-rg", + cluster_name="myCluster", + upload_certificate_request={"properties": {"certificates": ["base64cert", "base64cert"]}}, + ).result() + + +# x-ms-original-file: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/stable/2024-01-01/examples/UploadCertificate.json +if __name__ == "__main__": + main() diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/conftest.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/conftest.py new file mode 100644 index 000000000000..06f4bcf79e6c --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/conftest.py @@ -0,0 +1,35 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import os +import pytest +from dotenv import load_dotenv +from devtools_testutils import ( + test_proxy, + add_general_regex_sanitizer, + add_body_key_sanitizer, + add_header_regex_sanitizer, +) + +load_dotenv() + + +# aovid record sensitive identity information in recordings +@pytest.fixture(scope="session", autouse=True) +def add_sanitizers(test_proxy): + azurestackhci_subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") + azurestackhci_tenant_id = os.environ.get("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") + azurestackhci_client_id = os.environ.get("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000") + azurestackhci_client_secret = os.environ.get("AZURE_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=azurestackhci_subscription_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=azurestackhci_tenant_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=azurestackhci_client_id, value="00000000-0000-0000-0000-000000000000") + add_general_regex_sanitizer(regex=azurestackhci_client_secret, value="00000000-0000-0000-0000-000000000000") + + add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]") + add_header_regex_sanitizer(key="Cookie", value="cookie;") + add_body_key_sanitizer(json_path="$..access_token", value="access_token") diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_arc_settings_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_arc_settings_operations.py new file mode 100644 index 000000000000..5cd7502cff75 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_arc_settings_operations.py @@ -0,0 +1,161 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.azurestackhci import AzureStackHCIClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureStackHCIArcSettingsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureStackHCIClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_cluster(self, resource_group): + response = self.client.arc_settings.list_by_cluster( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-01-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.arc_settings.get( + resource_group_name=resource_group.name, + cluster_name="str", + arc_setting_name="str", + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create(self, resource_group): + response = self.client.arc_settings.create( + resource_group_name=resource_group.name, + cluster_name="str", + arc_setting_name="str", + arc_setting={ + "aggregateState": "str", + "arcApplicationClientId": "str", + "arcApplicationObjectId": "str", + "arcApplicationTenantId": "str", + "arcInstanceResourceGroup": "str", + "arcServicePrincipalObjectId": "str", + "connectivityProperties": {}, + "defaultExtensions": [{"category": "str", "consentTime": "2020-02-20 00:00:00"}], + "id": "str", + "name": "str", + "perNodeDetails": [ + {"arcInstance": "str", "arcNodeServicePrincipalObjectId": "str", "name": "str", "state": "str"} + ], + "provisioningState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.arc_settings.update( + resource_group_name=resource_group.name, + cluster_name="str", + arc_setting_name="str", + arc_setting={"connectivityProperties": {}, "tags": {"str": "str"}}, + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.arc_settings.begin_delete( + resource_group_name=resource_group.name, + cluster_name="str", + arc_setting_name="str", + api_version="2024-01-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_generate_password(self, resource_group): + response = self.client.arc_settings.generate_password( + resource_group_name=resource_group.name, + cluster_name="str", + arc_setting_name="str", + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_identity(self, resource_group): + response = self.client.arc_settings.begin_create_identity( + resource_group_name=resource_group.name, + cluster_name="str", + arc_setting_name="str", + api_version="2024-01-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_consent_and_install_default_extensions(self, resource_group): + response = self.client.arc_settings.consent_and_install_default_extensions( + resource_group_name=resource_group.name, + cluster_name="str", + arc_setting_name="str", + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_initialize_disable_process(self, resource_group): + response = self.client.arc_settings.begin_initialize_disable_process( + resource_group_name=resource_group.name, + cluster_name="str", + arc_setting_name="str", + api_version="2024-01-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_arc_settings_operations_async.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_arc_settings_operations_async.py new file mode 100644 index 000000000000..089dc3223572 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_arc_settings_operations_async.py @@ -0,0 +1,168 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.azurestackhci.aio import AzureStackHCIClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureStackHCIArcSettingsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureStackHCIClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_cluster(self, resource_group): + response = self.client.arc_settings.list_by_cluster( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-01-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.arc_settings.get( + resource_group_name=resource_group.name, + cluster_name="str", + arc_setting_name="str", + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create(self, resource_group): + response = await self.client.arc_settings.create( + resource_group_name=resource_group.name, + cluster_name="str", + arc_setting_name="str", + arc_setting={ + "aggregateState": "str", + "arcApplicationClientId": "str", + "arcApplicationObjectId": "str", + "arcApplicationTenantId": "str", + "arcInstanceResourceGroup": "str", + "arcServicePrincipalObjectId": "str", + "connectivityProperties": {}, + "defaultExtensions": [{"category": "str", "consentTime": "2020-02-20 00:00:00"}], + "id": "str", + "name": "str", + "perNodeDetails": [ + {"arcInstance": "str", "arcNodeServicePrincipalObjectId": "str", "name": "str", "state": "str"} + ], + "provisioningState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.arc_settings.update( + resource_group_name=resource_group.name, + cluster_name="str", + arc_setting_name="str", + arc_setting={"connectivityProperties": {}, "tags": {"str": "str"}}, + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.arc_settings.begin_delete( + resource_group_name=resource_group.name, + cluster_name="str", + arc_setting_name="str", + api_version="2024-01-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_generate_password(self, resource_group): + response = await self.client.arc_settings.generate_password( + resource_group_name=resource_group.name, + cluster_name="str", + arc_setting_name="str", + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_identity(self, resource_group): + response = await ( + await self.client.arc_settings.begin_create_identity( + resource_group_name=resource_group.name, + cluster_name="str", + arc_setting_name="str", + api_version="2024-01-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_consent_and_install_default_extensions(self, resource_group): + response = await self.client.arc_settings.consent_and_install_default_extensions( + resource_group_name=resource_group.name, + cluster_name="str", + arc_setting_name="str", + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_initialize_disable_process(self, resource_group): + response = await ( + await self.client.arc_settings.begin_initialize_disable_process( + resource_group_name=resource_group.name, + cluster_name="str", + arc_setting_name="str", + api_version="2024-01-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_clusters_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_clusters_operations.py new file mode 100644 index 000000000000..526e6290bfa9 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_clusters_operations.py @@ -0,0 +1,213 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.azurestackhci import AzureStackHCIClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureStackHCIClustersOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureStackHCIClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_subscription(self, resource_group): + response = self.client.clusters.list_by_subscription( + api_version="2024-01-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_resource_group(self, resource_group): + response = self.client.clusters.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2024-01-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.clusters.get( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create(self, resource_group): + response = self.client.clusters.create( + resource_group_name=resource_group.name, + cluster_name="str", + cluster={ + "location": "str", + "aadApplicationObjectId": "str", + "aadClientId": "str", + "aadServicePrincipalObjectId": "str", + "aadTenantId": "str", + "billingModel": "str", + "cloudId": "str", + "cloudManagementEndpoint": "str", + "connectivityStatus": "str", + "desiredProperties": {"diagnosticLevel": "str", "windowsServerSubscription": "str"}, + "id": "str", + "isolatedVmAttestationConfiguration": { + "attestationResourceId": "str", + "attestationServiceEndpoint": "str", + "relyingPartyServiceEndpoint": "str", + }, + "lastBillingTimestamp": "2020-02-20 00:00:00", + "lastSyncTimestamp": "2020-02-20 00:00:00", + "name": "str", + "principalId": "str", + "provisioningState": "str", + "registrationTimestamp": "2020-02-20 00:00:00", + "reportedProperties": { + "clusterId": "str", + "clusterName": "str", + "clusterType": "str", + "clusterVersion": "str", + "diagnosticLevel": "str", + "imdsAttestation": "str", + "lastUpdated": "2020-02-20 00:00:00", + "manufacturer": "str", + "nodes": [ + { + "coreCount": 0.0, + "ehcResourceId": "str", + "id": 0.0, + "lastLicensingTimestamp": "2020-02-20 00:00:00", + "manufacturer": "str", + "memoryInGiB": 0.0, + "model": "str", + "name": "str", + "nodeType": "str", + "oemActivation": "str", + "osDisplayVersion": "str", + "osName": "str", + "osVersion": "str", + "serialNumber": "str", + "windowsServerSubscription": "str", + } + ], + "oemActivation": "str", + "supportedCapabilities": ["str"], + }, + "resourceProviderObjectId": "str", + "serviceEndpoint": "str", + "softwareAssuranceProperties": { + "lastUpdated": "2020-02-20 00:00:00", + "softwareAssuranceIntent": "str", + "softwareAssuranceStatus": "str", + }, + "status": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "tenantId": "str", + "trialDaysRemaining": 0.0, + "type": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.clusters.update( + resource_group_name=resource_group.name, + cluster_name="str", + cluster={ + "aadClientId": "str", + "aadTenantId": "str", + "cloudManagementEndpoint": "str", + "desiredProperties": {"diagnosticLevel": "str", "windowsServerSubscription": "str"}, + "principalId": "str", + "tags": {"str": "str"}, + "tenantId": "str", + "type": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.clusters.begin_delete( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-01-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_upload_certificate(self, resource_group): + response = self.client.clusters.begin_upload_certificate( + resource_group_name=resource_group.name, + cluster_name="str", + upload_certificate_request={"properties": {"certificates": ["str"]}}, + api_version="2024-01-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_identity(self, resource_group): + response = self.client.clusters.begin_create_identity( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-01-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_extend_software_assurance_benefit(self, resource_group): + response = self.client.clusters.begin_extend_software_assurance_benefit( + resource_group_name=resource_group.name, + cluster_name="str", + software_assurance_change_request={"properties": {"softwareAssuranceIntent": "str"}}, + api_version="2024-01-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_clusters_operations_async.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_clusters_operations_async.py new file mode 100644 index 000000000000..df9aa031b7b1 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_clusters_operations_async.py @@ -0,0 +1,222 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.azurestackhci.aio import AzureStackHCIClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureStackHCIClustersOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureStackHCIClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_subscription(self, resource_group): + response = self.client.clusters.list_by_subscription( + api_version="2024-01-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_resource_group(self, resource_group): + response = self.client.clusters.list_by_resource_group( + resource_group_name=resource_group.name, + api_version="2024-01-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.clusters.get( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create(self, resource_group): + response = await self.client.clusters.create( + resource_group_name=resource_group.name, + cluster_name="str", + cluster={ + "location": "str", + "aadApplicationObjectId": "str", + "aadClientId": "str", + "aadServicePrincipalObjectId": "str", + "aadTenantId": "str", + "billingModel": "str", + "cloudId": "str", + "cloudManagementEndpoint": "str", + "connectivityStatus": "str", + "desiredProperties": {"diagnosticLevel": "str", "windowsServerSubscription": "str"}, + "id": "str", + "isolatedVmAttestationConfiguration": { + "attestationResourceId": "str", + "attestationServiceEndpoint": "str", + "relyingPartyServiceEndpoint": "str", + }, + "lastBillingTimestamp": "2020-02-20 00:00:00", + "lastSyncTimestamp": "2020-02-20 00:00:00", + "name": "str", + "principalId": "str", + "provisioningState": "str", + "registrationTimestamp": "2020-02-20 00:00:00", + "reportedProperties": { + "clusterId": "str", + "clusterName": "str", + "clusterType": "str", + "clusterVersion": "str", + "diagnosticLevel": "str", + "imdsAttestation": "str", + "lastUpdated": "2020-02-20 00:00:00", + "manufacturer": "str", + "nodes": [ + { + "coreCount": 0.0, + "ehcResourceId": "str", + "id": 0.0, + "lastLicensingTimestamp": "2020-02-20 00:00:00", + "manufacturer": "str", + "memoryInGiB": 0.0, + "model": "str", + "name": "str", + "nodeType": "str", + "oemActivation": "str", + "osDisplayVersion": "str", + "osName": "str", + "osVersion": "str", + "serialNumber": "str", + "windowsServerSubscription": "str", + } + ], + "oemActivation": "str", + "supportedCapabilities": ["str"], + }, + "resourceProviderObjectId": "str", + "serviceEndpoint": "str", + "softwareAssuranceProperties": { + "lastUpdated": "2020-02-20 00:00:00", + "softwareAssuranceIntent": "str", + "softwareAssuranceStatus": "str", + }, + "status": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "tenantId": "str", + "trialDaysRemaining": 0.0, + "type": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.clusters.update( + resource_group_name=resource_group.name, + cluster_name="str", + cluster={ + "aadClientId": "str", + "aadTenantId": "str", + "cloudManagementEndpoint": "str", + "desiredProperties": {"diagnosticLevel": "str", "windowsServerSubscription": "str"}, + "principalId": "str", + "tags": {"str": "str"}, + "tenantId": "str", + "type": "str", + "userAssignedIdentities": {"str": {"clientId": "str", "principalId": "str"}}, + }, + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.clusters.begin_delete( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-01-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_upload_certificate(self, resource_group): + response = await ( + await self.client.clusters.begin_upload_certificate( + resource_group_name=resource_group.name, + cluster_name="str", + upload_certificate_request={"properties": {"certificates": ["str"]}}, + api_version="2024-01-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_identity(self, resource_group): + response = await ( + await self.client.clusters.begin_create_identity( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-01-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_extend_software_assurance_benefit(self, resource_group): + response = await ( + await self.client.clusters.begin_extend_software_assurance_benefit( + resource_group_name=resource_group.name, + cluster_name="str", + software_assurance_change_request={"properties": {"softwareAssuranceIntent": "str"}}, + api_version="2024-01-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_deployment_settings_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_deployment_settings_operations.py new file mode 100644 index 000000000000..7f74ee5c0879 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_deployment_settings_operations.py @@ -0,0 +1,196 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.azurestackhci import AzureStackHCIClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureStackHCIDeploymentSettingsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureStackHCIClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_clusters(self, resource_group): + response = self.client.deployment_settings.list_by_clusters( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-01-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.deployment_settings.get( + resource_group_name=resource_group.name, + cluster_name="str", + deployment_settings_name="default", + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.deployment_settings.begin_create_or_update( + resource_group_name=resource_group.name, + cluster_name="str", + resource={ + "arcNodeResourceIds": ["str"], + "deploymentConfiguration": { + "scaleUnits": [ + { + "deploymentData": { + "adouPath": "str", + "cluster": { + "azureServiceEndpoint": "str", + "cloudAccountName": "str", + "name": "str", + "witnessPath": "str", + "witnessType": "str", + }, + "domainFqdn": "str", + "hostNetwork": { + "enableStorageAutoIp": False, + "intents": [ + { + "adapter": ["str"], + "adapterPropertyOverrides": { + "jumboPacket": "str", + "networkDirect": "str", + "networkDirectTechnology": "str", + }, + "name": "str", + "overrideAdapterProperty": False, + "overrideQosPolicy": False, + "overrideVirtualSwitchConfiguration": False, + "qosPolicyOverrides": { + "bandwidthPercentage_SMB": "str", + "priorityValue8021Action_Cluster": "str", + "priorityValue8021Action_SMB": "str", + }, + "trafficType": ["str"], + "virtualSwitchConfigurationOverrides": { + "enableIov": "str", + "loadBalancingAlgorithm": "str", + }, + } + ], + "storageConnectivitySwitchless": False, + "storageNetworks": [{"name": "str", "networkAdapterName": "str", "vlanId": "str"}], + }, + "infrastructureNetwork": [ + { + "dnsServers": ["str"], + "gateway": "str", + "ipPools": [{"endingAddress": "str", "startingAddress": "str"}], + "subnetMask": "str", + "useDhcp": bool, + } + ], + "namingPrefix": "str", + "observability": { + "episodicDataUpload": True, + "euLocation": False, + "streamingDataClient": True, + }, + "optionalServices": {"customLocation": "str"}, + "physicalNodes": [{"ipv4Address": "str", "name": "str"}], + "secretsLocation": "str", + "securitySettings": { + "bitlockerBootVolume": True, + "bitlockerDataVolumes": True, + "credentialGuardEnforced": False, + "driftControlEnforced": True, + "drtmProtection": True, + "hvciProtection": True, + "sideChannelMitigationEnforced": True, + "smbClusterEncryption": False, + "smbSigningEnforced": True, + "wdacEnforced": True, + }, + "storage": {"configurationMode": "Express"}, + } + } + ], + "version": "str", + }, + "deploymentMode": "Deploy", + "id": "str", + "name": "str", + "provisioningState": "str", + "reportedProperties": { + "deploymentStatus": { + "status": "str", + "steps": [ + { + "description": "str", + "endTimeUtc": "str", + "exception": ["str"], + "fullStepIndex": "str", + "name": "str", + "startTimeUtc": "str", + "status": "str", + "steps": [...], + } + ], + }, + "validationStatus": { + "status": "str", + "steps": [ + { + "description": "str", + "endTimeUtc": "str", + "exception": ["str"], + "fullStepIndex": "str", + "name": "str", + "startTimeUtc": "str", + "status": "str", + "steps": [...], + } + ], + }, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + deployment_settings_name="default", + api_version="2024-01-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.deployment_settings.begin_delete( + resource_group_name=resource_group.name, + cluster_name="str", + deployment_settings_name="default", + api_version="2024-01-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_deployment_settings_operations_async.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_deployment_settings_operations_async.py new file mode 100644 index 000000000000..39c889fe8aa8 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_deployment_settings_operations_async.py @@ -0,0 +1,203 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.azurestackhci.aio import AzureStackHCIClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureStackHCIDeploymentSettingsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureStackHCIClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_clusters(self, resource_group): + response = self.client.deployment_settings.list_by_clusters( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-01-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.deployment_settings.get( + resource_group_name=resource_group.name, + cluster_name="str", + deployment_settings_name="default", + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.deployment_settings.begin_create_or_update( + resource_group_name=resource_group.name, + cluster_name="str", + resource={ + "arcNodeResourceIds": ["str"], + "deploymentConfiguration": { + "scaleUnits": [ + { + "deploymentData": { + "adouPath": "str", + "cluster": { + "azureServiceEndpoint": "str", + "cloudAccountName": "str", + "name": "str", + "witnessPath": "str", + "witnessType": "str", + }, + "domainFqdn": "str", + "hostNetwork": { + "enableStorageAutoIp": False, + "intents": [ + { + "adapter": ["str"], + "adapterPropertyOverrides": { + "jumboPacket": "str", + "networkDirect": "str", + "networkDirectTechnology": "str", + }, + "name": "str", + "overrideAdapterProperty": False, + "overrideQosPolicy": False, + "overrideVirtualSwitchConfiguration": False, + "qosPolicyOverrides": { + "bandwidthPercentage_SMB": "str", + "priorityValue8021Action_Cluster": "str", + "priorityValue8021Action_SMB": "str", + }, + "trafficType": ["str"], + "virtualSwitchConfigurationOverrides": { + "enableIov": "str", + "loadBalancingAlgorithm": "str", + }, + } + ], + "storageConnectivitySwitchless": False, + "storageNetworks": [ + {"name": "str", "networkAdapterName": "str", "vlanId": "str"} + ], + }, + "infrastructureNetwork": [ + { + "dnsServers": ["str"], + "gateway": "str", + "ipPools": [{"endingAddress": "str", "startingAddress": "str"}], + "subnetMask": "str", + "useDhcp": bool, + } + ], + "namingPrefix": "str", + "observability": { + "episodicDataUpload": True, + "euLocation": False, + "streamingDataClient": True, + }, + "optionalServices": {"customLocation": "str"}, + "physicalNodes": [{"ipv4Address": "str", "name": "str"}], + "secretsLocation": "str", + "securitySettings": { + "bitlockerBootVolume": True, + "bitlockerDataVolumes": True, + "credentialGuardEnforced": False, + "driftControlEnforced": True, + "drtmProtection": True, + "hvciProtection": True, + "sideChannelMitigationEnforced": True, + "smbClusterEncryption": False, + "smbSigningEnforced": True, + "wdacEnforced": True, + }, + "storage": {"configurationMode": "Express"}, + } + } + ], + "version": "str", + }, + "deploymentMode": "Deploy", + "id": "str", + "name": "str", + "provisioningState": "str", + "reportedProperties": { + "deploymentStatus": { + "status": "str", + "steps": [ + { + "description": "str", + "endTimeUtc": "str", + "exception": ["str"], + "fullStepIndex": "str", + "name": "str", + "startTimeUtc": "str", + "status": "str", + "steps": [...], + } + ], + }, + "validationStatus": { + "status": "str", + "steps": [ + { + "description": "str", + "endTimeUtc": "str", + "exception": ["str"], + "fullStepIndex": "str", + "name": "str", + "startTimeUtc": "str", + "status": "str", + "steps": [...], + } + ], + }, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + deployment_settings_name="default", + api_version="2024-01-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.deployment_settings.begin_delete( + resource_group_name=resource_group.name, + cluster_name="str", + deployment_settings_name="default", + api_version="2024-01-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_edge_devices_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_edge_devices_operations.py new file mode 100644 index 000000000000..57db08839e14 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_edge_devices_operations.py @@ -0,0 +1,109 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.azurestackhci import AzureStackHCIClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureStackHCIEdgeDevicesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureStackHCIClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.edge_devices.list( + resource_uri="str", + api_version="2024-01-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.edge_devices.get( + resource_uri="str", + edge_device_name="default", + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.edge_devices.begin_create_or_update( + resource_uri="str", + resource={ + "deviceConfiguration": { + "deviceMetadata": "str", + "nicDetails": [ + { + "adapterName": "str", + "componentId": "str", + "defaultGateway": "str", + "defaultIsolationId": "str", + "dnsServers": ["str"], + "driverVersion": "str", + "interfaceDescription": "str", + "ip4Address": "str", + "subnetMask": "str", + } + ], + }, + "id": "str", + "name": "str", + "provisioningState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + edge_device_name="default", + api_version="2024-01-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.edge_devices.begin_delete( + resource_uri="str", + edge_device_name="default", + api_version="2024-01-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_validate(self, resource_group): + response = self.client.edge_devices.begin_validate( + resource_uri="str", + validate_request={"edgeDeviceIds": ["str"], "additionalInfo": "str"}, + edge_device_name="default", + api_version="2024-01-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_edge_devices_operations_async.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_edge_devices_operations_async.py new file mode 100644 index 000000000000..a9abe252fd3c --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_edge_devices_operations_async.py @@ -0,0 +1,116 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.azurestackhci.aio import AzureStackHCIClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureStackHCIEdgeDevicesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureStackHCIClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.edge_devices.list( + resource_uri="str", + api_version="2024-01-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.edge_devices.get( + resource_uri="str", + edge_device_name="default", + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.edge_devices.begin_create_or_update( + resource_uri="str", + resource={ + "deviceConfiguration": { + "deviceMetadata": "str", + "nicDetails": [ + { + "adapterName": "str", + "componentId": "str", + "defaultGateway": "str", + "defaultIsolationId": "str", + "dnsServers": ["str"], + "driverVersion": "str", + "interfaceDescription": "str", + "ip4Address": "str", + "subnetMask": "str", + } + ], + }, + "id": "str", + "name": "str", + "provisioningState": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + edge_device_name="default", + api_version="2024-01-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.edge_devices.begin_delete( + resource_uri="str", + edge_device_name="default", + api_version="2024-01-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_validate(self, resource_group): + response = await ( + await self.client.edge_devices.begin_validate( + resource_uri="str", + validate_request={"edgeDeviceIds": ["str"], "additionalInfo": "str"}, + edge_device_name="default", + api_version="2024-01-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_extensions_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_extensions_operations.py new file mode 100644 index 000000000000..b0fb6176ebd7 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_extensions_operations.py @@ -0,0 +1,154 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.azurestackhci import AzureStackHCIClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureStackHCIExtensionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureStackHCIClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_arc_setting(self, resource_group): + response = self.client.extensions.list_by_arc_setting( + resource_group_name=resource_group.name, + cluster_name="str", + arc_setting_name="str", + api_version="2024-01-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.extensions.get( + resource_group_name=resource_group.name, + cluster_name="str", + arc_setting_name="str", + extension_name="str", + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create(self, resource_group): + response = self.client.extensions.begin_create( + resource_group_name=resource_group.name, + cluster_name="str", + arc_setting_name="str", + extension_name="str", + extension={ + "aggregateState": "str", + "autoUpgradeMinorVersion": bool, + "enableAutomaticUpgrade": bool, + "forceUpdateTag": "str", + "id": "str", + "managedBy": "str", + "name": "str", + "perNodeExtensionDetails": [ + { + "extension": "str", + "instanceView": { + "name": "str", + "status": { + "code": "str", + "displayStatus": "str", + "level": "str", + "message": "str", + "time": "2020-02-20 00:00:00", + }, + "type": "str", + "typeHandlerVersion": "str", + }, + "name": "str", + "state": "str", + "typeHandlerVersion": "str", + } + ], + "protectedSettings": {}, + "provisioningState": "str", + "publisher": "str", + "settings": {}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + "typeHandlerVersion": "str", + }, + api_version="2024-01-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.extensions.begin_update( + resource_group_name=resource_group.name, + cluster_name="str", + arc_setting_name="str", + extension_name="str", + extension={ + "extensionParameters": { + "enableAutomaticUpgrade": bool, + "protectedSettings": {}, + "settings": {}, + "typeHandlerVersion": "str", + } + }, + api_version="2024-01-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.extensions.begin_delete( + resource_group_name=resource_group.name, + cluster_name="str", + arc_setting_name="str", + extension_name="str", + api_version="2024-01-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_upgrade(self, resource_group): + response = self.client.extensions.begin_upgrade( + resource_group_name=resource_group.name, + cluster_name="str", + arc_setting_name="str", + extension_name="str", + extension_upgrade_parameters={"targetVersion": "str"}, + api_version="2024-01-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_extensions_operations_async.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_extensions_operations_async.py new file mode 100644 index 000000000000..9ce48bb35b50 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_extensions_operations_async.py @@ -0,0 +1,163 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.azurestackhci.aio import AzureStackHCIClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureStackHCIExtensionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureStackHCIClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_arc_setting(self, resource_group): + response = self.client.extensions.list_by_arc_setting( + resource_group_name=resource_group.name, + cluster_name="str", + arc_setting_name="str", + api_version="2024-01-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.extensions.get( + resource_group_name=resource_group.name, + cluster_name="str", + arc_setting_name="str", + extension_name="str", + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create(self, resource_group): + response = await ( + await self.client.extensions.begin_create( + resource_group_name=resource_group.name, + cluster_name="str", + arc_setting_name="str", + extension_name="str", + extension={ + "aggregateState": "str", + "autoUpgradeMinorVersion": bool, + "enableAutomaticUpgrade": bool, + "forceUpdateTag": "str", + "id": "str", + "managedBy": "str", + "name": "str", + "perNodeExtensionDetails": [ + { + "extension": "str", + "instanceView": { + "name": "str", + "status": { + "code": "str", + "displayStatus": "str", + "level": "str", + "message": "str", + "time": "2020-02-20 00:00:00", + }, + "type": "str", + "typeHandlerVersion": "str", + }, + "name": "str", + "state": "str", + "typeHandlerVersion": "str", + } + ], + "protectedSettings": {}, + "provisioningState": "str", + "publisher": "str", + "settings": {}, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + "typeHandlerVersion": "str", + }, + api_version="2024-01-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.extensions.begin_update( + resource_group_name=resource_group.name, + cluster_name="str", + arc_setting_name="str", + extension_name="str", + extension={ + "extensionParameters": { + "enableAutomaticUpgrade": bool, + "protectedSettings": {}, + "settings": {}, + "typeHandlerVersion": "str", + } + }, + api_version="2024-01-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.extensions.begin_delete( + resource_group_name=resource_group.name, + cluster_name="str", + arc_setting_name="str", + extension_name="str", + api_version="2024-01-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_upgrade(self, resource_group): + response = await ( + await self.client.extensions.begin_upgrade( + resource_group_name=resource_group.name, + cluster_name="str", + arc_setting_name="str", + extension_name="str", + extension_upgrade_parameters={"targetVersion": "str"}, + api_version="2024-01-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_gallery_images_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_gallery_images_operations.py new file mode 100644 index 000000000000..3cef592bb8de --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_gallery_images_operations.py @@ -0,0 +1,120 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.azurestackhci import AzureStackHCIClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureStackHCIGalleryImagesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureStackHCIClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.gallery_images.get( + resource_group_name=resource_group.name, + gallery_image_name="str", + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.gallery_images.begin_create_or_update( + resource_group_name=resource_group.name, + gallery_image_name="str", + gallery_images={ + "location": "str", + "cloudInitDataSource": "str", + "containerId": "str", + "extendedLocation": {"name": "str", "type": "str"}, + "hyperVGeneration": "str", + "id": "str", + "identifier": {"offer": "str", "publisher": "str", "sku": "str"}, + "imagePath": "str", + "name": "str", + "osType": "str", + "provisioningState": "str", + "status": { + "downloadStatus": {"downloadSizeInMB": 0}, + "errorCode": "str", + "errorMessage": "str", + "progressPercentage": 0, + "provisioningStatus": {"operationId": "str", "status": "str"}, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + "version": {"name": "str", "storageProfile": {"osDiskImage": {"sizeInMB": 0}}}, + }, + api_version="2024-01-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.gallery_images.begin_delete( + resource_group_name=resource_group.name, + gallery_image_name="str", + api_version="2024-01-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.gallery_images.begin_update( + resource_group_name=resource_group.name, + gallery_image_name="str", + gallery_images={"tags": {"str": "str"}}, + api_version="2024-01-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.gallery_images.list( + resource_group_name=resource_group.name, + api_version="2024-01-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_all(self, resource_group): + response = self.client.gallery_images.list_all( + api_version="2024-01-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_gallery_images_operations_async.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_gallery_images_operations_async.py new file mode 100644 index 000000000000..e8635ee9db97 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_gallery_images_operations_async.py @@ -0,0 +1,127 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.azurestackhci.aio import AzureStackHCIClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureStackHCIGalleryImagesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureStackHCIClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.gallery_images.get( + resource_group_name=resource_group.name, + gallery_image_name="str", + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.gallery_images.begin_create_or_update( + resource_group_name=resource_group.name, + gallery_image_name="str", + gallery_images={ + "location": "str", + "cloudInitDataSource": "str", + "containerId": "str", + "extendedLocation": {"name": "str", "type": "str"}, + "hyperVGeneration": "str", + "id": "str", + "identifier": {"offer": "str", "publisher": "str", "sku": "str"}, + "imagePath": "str", + "name": "str", + "osType": "str", + "provisioningState": "str", + "status": { + "downloadStatus": {"downloadSizeInMB": 0}, + "errorCode": "str", + "errorMessage": "str", + "progressPercentage": 0, + "provisioningStatus": {"operationId": "str", "status": "str"}, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + "version": {"name": "str", "storageProfile": {"osDiskImage": {"sizeInMB": 0}}}, + }, + api_version="2024-01-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.gallery_images.begin_delete( + resource_group_name=resource_group.name, + gallery_image_name="str", + api_version="2024-01-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.gallery_images.begin_update( + resource_group_name=resource_group.name, + gallery_image_name="str", + gallery_images={"tags": {"str": "str"}}, + api_version="2024-01-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.gallery_images.list( + resource_group_name=resource_group.name, + api_version="2024-01-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_all(self, resource_group): + response = self.client.gallery_images.list_all( + api_version="2024-01-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_guest_agent_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_guest_agent_operations.py new file mode 100644 index 000000000000..ce615e953b5f --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_guest_agent_operations.py @@ -0,0 +1,52 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.azurestackhci import AzureStackHCIClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureStackHCIGuestAgentOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureStackHCIClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create(self, resource_group): + response = self.client.guest_agent.begin_create( + resource_uri="str", + api_version="2024-01-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.guest_agent.get( + resource_uri="str", + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.guest_agent.begin_delete( + resource_uri="str", + api_version="2024-01-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_guest_agent_operations_async.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_guest_agent_operations_async.py new file mode 100644 index 000000000000..1c1797a03ff1 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_guest_agent_operations_async.py @@ -0,0 +1,57 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.azurestackhci.aio import AzureStackHCIClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureStackHCIGuestAgentOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureStackHCIClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create(self, resource_group): + response = await ( + await self.client.guest_agent.begin_create( + resource_uri="str", + api_version="2024-01-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.guest_agent.get( + resource_uri="str", + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.guest_agent.begin_delete( + resource_uri="str", + api_version="2024-01-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_guest_agents_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_guest_agents_operations.py new file mode 100644 index 000000000000..9f48b16d24ca --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_guest_agents_operations.py @@ -0,0 +1,30 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.azurestackhci import AzureStackHCIClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureStackHCIGuestAgentsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureStackHCIClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.guest_agents.list( + resource_uri="str", + api_version="2024-01-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_guest_agents_operations_async.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_guest_agents_operations_async.py new file mode 100644 index 000000000000..0aeea451ee51 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_guest_agents_operations_async.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.azurestackhci.aio import AzureStackHCIClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureStackHCIGuestAgentsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureStackHCIClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.guest_agents.list( + resource_uri="str", + api_version="2024-01-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_hybrid_identity_metadata_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_hybrid_identity_metadata_operations.py new file mode 100644 index 000000000000..17d317053007 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_hybrid_identity_metadata_operations.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.azurestackhci import AzureStackHCIClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureStackHCIHybridIdentityMetadataOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureStackHCIClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.hybrid_identity_metadata.get( + resource_uri="str", + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.hybrid_identity_metadata.list( + resource_uri="str", + api_version="2024-01-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_hybrid_identity_metadata_operations_async.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_hybrid_identity_metadata_operations_async.py new file mode 100644 index 000000000000..982d8a290363 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_hybrid_identity_metadata_operations_async.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.azurestackhci.aio import AzureStackHCIClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureStackHCIHybridIdentityMetadataOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureStackHCIClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.hybrid_identity_metadata.get( + resource_uri="str", + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.hybrid_identity_metadata.list( + resource_uri="str", + api_version="2024-01-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_logical_networks_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_logical_networks_operations.py new file mode 100644 index 000000000000..6f73b696f143 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_logical_networks_operations.py @@ -0,0 +1,138 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.azurestackhci import AzureStackHCIClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureStackHCILogicalNetworksOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureStackHCIClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.logical_networks.get( + resource_group_name=resource_group.name, + logical_network_name="str", + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.logical_networks.begin_create_or_update( + resource_group_name=resource_group.name, + logical_network_name="str", + logical_networks={ + "location": "str", + "dhcpOptions": {"dnsServers": ["str"]}, + "extendedLocation": {"name": "str", "type": "str"}, + "id": "str", + "name": "str", + "provisioningState": "str", + "status": { + "errorCode": "str", + "errorMessage": "str", + "provisioningStatus": {"operationId": "str", "status": "str"}, + }, + "subnets": [ + { + "addressPrefix": "str", + "addressPrefixes": ["str"], + "ipAllocationMethod": "str", + "ipConfigurationReferences": [{"ID": "str"}], + "ipPools": [ + { + "end": "str", + "info": {"available": "str", "used": "str"}, + "ipPoolType": "str", + "name": "str", + "start": "str", + } + ], + "name": "str", + "routeTable": { + "etag": "str", + "name": "str", + "routes": [{"addressPrefix": "str", "name": "str", "nextHopIpAddress": "str"}], + "type": "str", + }, + "vlan": 0, + } + ], + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + "vmSwitchName": "str", + }, + api_version="2024-01-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.logical_networks.begin_delete( + resource_group_name=resource_group.name, + logical_network_name="str", + api_version="2024-01-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.logical_networks.begin_update( + resource_group_name=resource_group.name, + logical_network_name="str", + logical_networks={"tags": {"str": "str"}}, + api_version="2024-01-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.logical_networks.list( + resource_group_name=resource_group.name, + api_version="2024-01-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_all(self, resource_group): + response = self.client.logical_networks.list_all( + api_version="2024-01-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_logical_networks_operations_async.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_logical_networks_operations_async.py new file mode 100644 index 000000000000..af16c1f07959 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_logical_networks_operations_async.py @@ -0,0 +1,145 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.azurestackhci.aio import AzureStackHCIClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureStackHCILogicalNetworksOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureStackHCIClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.logical_networks.get( + resource_group_name=resource_group.name, + logical_network_name="str", + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.logical_networks.begin_create_or_update( + resource_group_name=resource_group.name, + logical_network_name="str", + logical_networks={ + "location": "str", + "dhcpOptions": {"dnsServers": ["str"]}, + "extendedLocation": {"name": "str", "type": "str"}, + "id": "str", + "name": "str", + "provisioningState": "str", + "status": { + "errorCode": "str", + "errorMessage": "str", + "provisioningStatus": {"operationId": "str", "status": "str"}, + }, + "subnets": [ + { + "addressPrefix": "str", + "addressPrefixes": ["str"], + "ipAllocationMethod": "str", + "ipConfigurationReferences": [{"ID": "str"}], + "ipPools": [ + { + "end": "str", + "info": {"available": "str", "used": "str"}, + "ipPoolType": "str", + "name": "str", + "start": "str", + } + ], + "name": "str", + "routeTable": { + "etag": "str", + "name": "str", + "routes": [{"addressPrefix": "str", "name": "str", "nextHopIpAddress": "str"}], + "type": "str", + }, + "vlan": 0, + } + ], + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + "vmSwitchName": "str", + }, + api_version="2024-01-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.logical_networks.begin_delete( + resource_group_name=resource_group.name, + logical_network_name="str", + api_version="2024-01-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.logical_networks.begin_update( + resource_group_name=resource_group.name, + logical_network_name="str", + logical_networks={"tags": {"str": "str"}}, + api_version="2024-01-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.logical_networks.list( + resource_group_name=resource_group.name, + api_version="2024-01-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_all(self, resource_group): + response = self.client.logical_networks.list_all( + api_version="2024-01-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_marketplace_gallery_images_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_marketplace_gallery_images_operations.py new file mode 100644 index 000000000000..26bd8e95ad20 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_marketplace_gallery_images_operations.py @@ -0,0 +1,119 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.azurestackhci import AzureStackHCIClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureStackHCIMarketplaceGalleryImagesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureStackHCIClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.marketplace_gallery_images.get( + resource_group_name=resource_group.name, + marketplace_gallery_image_name="str", + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.marketplace_gallery_images.begin_create_or_update( + resource_group_name=resource_group.name, + marketplace_gallery_image_name="str", + marketplace_gallery_images={ + "location": "str", + "cloudInitDataSource": "str", + "containerId": "str", + "extendedLocation": {"name": "str", "type": "str"}, + "hyperVGeneration": "str", + "id": "str", + "identifier": {"offer": "str", "publisher": "str", "sku": "str"}, + "name": "str", + "osType": "str", + "provisioningState": "str", + "status": { + "downloadStatus": {"downloadSizeInMB": 0}, + "errorCode": "str", + "errorMessage": "str", + "progressPercentage": 0, + "provisioningStatus": {"operationId": "str", "status": "str"}, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + "version": {"name": "str", "storageProfile": {"osDiskImage": {"sizeInMB": 0}}}, + }, + api_version="2024-01-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.marketplace_gallery_images.begin_delete( + resource_group_name=resource_group.name, + marketplace_gallery_image_name="str", + api_version="2024-01-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.marketplace_gallery_images.begin_update( + resource_group_name=resource_group.name, + marketplace_gallery_image_name="str", + marketplace_gallery_images={"tags": {"str": "str"}}, + api_version="2024-01-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.marketplace_gallery_images.list( + resource_group_name=resource_group.name, + api_version="2024-01-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_all(self, resource_group): + response = self.client.marketplace_gallery_images.list_all( + api_version="2024-01-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_marketplace_gallery_images_operations_async.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_marketplace_gallery_images_operations_async.py new file mode 100644 index 000000000000..bde589c394a7 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_marketplace_gallery_images_operations_async.py @@ -0,0 +1,126 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.azurestackhci.aio import AzureStackHCIClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureStackHCIMarketplaceGalleryImagesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureStackHCIClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.marketplace_gallery_images.get( + resource_group_name=resource_group.name, + marketplace_gallery_image_name="str", + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.marketplace_gallery_images.begin_create_or_update( + resource_group_name=resource_group.name, + marketplace_gallery_image_name="str", + marketplace_gallery_images={ + "location": "str", + "cloudInitDataSource": "str", + "containerId": "str", + "extendedLocation": {"name": "str", "type": "str"}, + "hyperVGeneration": "str", + "id": "str", + "identifier": {"offer": "str", "publisher": "str", "sku": "str"}, + "name": "str", + "osType": "str", + "provisioningState": "str", + "status": { + "downloadStatus": {"downloadSizeInMB": 0}, + "errorCode": "str", + "errorMessage": "str", + "progressPercentage": 0, + "provisioningStatus": {"operationId": "str", "status": "str"}, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + "version": {"name": "str", "storageProfile": {"osDiskImage": {"sizeInMB": 0}}}, + }, + api_version="2024-01-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.marketplace_gallery_images.begin_delete( + resource_group_name=resource_group.name, + marketplace_gallery_image_name="str", + api_version="2024-01-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.marketplace_gallery_images.begin_update( + resource_group_name=resource_group.name, + marketplace_gallery_image_name="str", + marketplace_gallery_images={"tags": {"str": "str"}}, + api_version="2024-01-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.marketplace_gallery_images.list( + resource_group_name=resource_group.name, + api_version="2024-01-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_all(self, resource_group): + response = self.client.marketplace_gallery_images.list_all( + api_version="2024-01-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_network_interfaces_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_network_interfaces_operations.py new file mode 100644 index 000000000000..bb2217074820 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_network_interfaces_operations.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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.azurestackhci import AzureStackHCIClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureStackHCINetworkInterfacesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureStackHCIClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.network_interfaces.get( + resource_group_name=resource_group.name, + network_interface_name="str", + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.network_interfaces.begin_create_or_update( + resource_group_name=resource_group.name, + network_interface_name="str", + network_interfaces={ + "location": "str", + "dnsSettings": {"dnsServers": ["str"]}, + "extendedLocation": {"name": "str", "type": "str"}, + "id": "str", + "ipConfigurations": [ + { + "name": "str", + "properties": { + "gateway": "str", + "prefixLength": "str", + "privateIPAddress": "str", + "subnet": {"id": "str"}, + }, + } + ], + "macAddress": "str", + "name": "str", + "provisioningState": "str", + "status": { + "errorCode": "str", + "errorMessage": "str", + "provisioningStatus": {"operationId": "str", "status": "str"}, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2024-01-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.network_interfaces.begin_delete( + resource_group_name=resource_group.name, + network_interface_name="str", + api_version="2024-01-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.network_interfaces.begin_update( + resource_group_name=resource_group.name, + network_interface_name="str", + network_interfaces={"tags": {"str": "str"}}, + api_version="2024-01-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.network_interfaces.list( + resource_group_name=resource_group.name, + api_version="2024-01-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_all(self, resource_group): + response = self.client.network_interfaces.list_all( + api_version="2024-01-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_network_interfaces_operations_async.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_network_interfaces_operations_async.py new file mode 100644 index 000000000000..9214d180b730 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_network_interfaces_operations_async.py @@ -0,0 +1,131 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.azurestackhci.aio import AzureStackHCIClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureStackHCINetworkInterfacesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureStackHCIClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.network_interfaces.get( + resource_group_name=resource_group.name, + network_interface_name="str", + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.network_interfaces.begin_create_or_update( + resource_group_name=resource_group.name, + network_interface_name="str", + network_interfaces={ + "location": "str", + "dnsSettings": {"dnsServers": ["str"]}, + "extendedLocation": {"name": "str", "type": "str"}, + "id": "str", + "ipConfigurations": [ + { + "name": "str", + "properties": { + "gateway": "str", + "prefixLength": "str", + "privateIPAddress": "str", + "subnet": {"id": "str"}, + }, + } + ], + "macAddress": "str", + "name": "str", + "provisioningState": "str", + "status": { + "errorCode": "str", + "errorMessage": "str", + "provisioningStatus": {"operationId": "str", "status": "str"}, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2024-01-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.network_interfaces.begin_delete( + resource_group_name=resource_group.name, + network_interface_name="str", + api_version="2024-01-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.network_interfaces.begin_update( + resource_group_name=resource_group.name, + network_interface_name="str", + network_interfaces={"tags": {"str": "str"}}, + api_version="2024-01-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.network_interfaces.list( + resource_group_name=resource_group.name, + api_version="2024-01-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_all(self, resource_group): + response = self.client.network_interfaces.list_all( + api_version="2024-01-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_offers_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_offers_operations.py new file mode 100644 index 000000000000..7a62e37bae9d --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_offers_operations.py @@ -0,0 +1,58 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.azurestackhci import AzureStackHCIClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureStackHCIOffersOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureStackHCIClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_publisher(self, resource_group): + response = self.client.offers.list_by_publisher( + resource_group_name=resource_group.name, + cluster_name="str", + publisher_name="str", + api_version="2024-01-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_cluster(self, resource_group): + response = self.client.offers.list_by_cluster( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-01-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.offers.get( + resource_group_name=resource_group.name, + cluster_name="str", + publisher_name="str", + offer_name="str", + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_offers_operations_async.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_offers_operations_async.py new file mode 100644 index 000000000000..3c55f4ec6ba8 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_offers_operations_async.py @@ -0,0 +1,59 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.azurestackhci.aio import AzureStackHCIClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureStackHCIOffersOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureStackHCIClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_publisher(self, resource_group): + response = self.client.offers.list_by_publisher( + resource_group_name=resource_group.name, + cluster_name="str", + publisher_name="str", + api_version="2024-01-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_cluster(self, resource_group): + response = self.client.offers.list_by_cluster( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-01-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.offers.get( + resource_group_name=resource_group.name, + cluster_name="str", + publisher_name="str", + offer_name="str", + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_operations.py new file mode 100644 index 000000000000..492a07d0012d --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_operations.py @@ -0,0 +1,29 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.azurestackhci import AzureStackHCIClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureStackHCIOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureStackHCIClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.operations.list( + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_operations_async.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_operations_async.py new file mode 100644 index 000000000000..f2804ea38b43 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_operations_async.py @@ -0,0 +1,30 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.azurestackhci.aio import AzureStackHCIClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureStackHCIOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureStackHCIClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = await self.client.operations.list( + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_publishers_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_publishers_operations.py new file mode 100644 index 000000000000..408151d8be8b --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_publishers_operations.py @@ -0,0 +1,44 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.azurestackhci import AzureStackHCIClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureStackHCIPublishersOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureStackHCIClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_cluster(self, resource_group): + response = self.client.publishers.list_by_cluster( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-01-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.publishers.get( + resource_group_name=resource_group.name, + cluster_name="str", + publisher_name="str", + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_publishers_operations_async.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_publishers_operations_async.py new file mode 100644 index 000000000000..803ebbd3aded --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_publishers_operations_async.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.azurestackhci.aio import AzureStackHCIClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureStackHCIPublishersOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureStackHCIClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_cluster(self, resource_group): + response = self.client.publishers.list_by_cluster( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-01-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.publishers.get( + resource_group_name=resource_group.name, + cluster_name="str", + publisher_name="str", + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_security_settings_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_security_settings_operations.py new file mode 100644 index 000000000000..1385900f0103 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_security_settings_operations.py @@ -0,0 +1,92 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.azurestackhci import AzureStackHCIClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureStackHCISecuritySettingsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureStackHCIClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_clusters(self, resource_group): + response = self.client.security_settings.list_by_clusters( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-01-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.security_settings.get( + resource_group_name=resource_group.name, + cluster_name="str", + security_settings_name="default", + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.security_settings.begin_create_or_update( + resource_group_name=resource_group.name, + cluster_name="str", + resource={ + "id": "str", + "name": "str", + "provisioningState": "str", + "securedCoreComplianceAssignment": "str", + "securityComplianceStatus": { + "dataAtRestEncrypted": "str", + "dataInTransitProtected": "str", + "lastUpdated": "2020-02-20 00:00:00", + "securedCoreCompliance": "str", + "wdacCompliance": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + security_settings_name="default", + api_version="2024-01-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.security_settings.begin_delete( + resource_group_name=resource_group.name, + cluster_name="str", + security_settings_name="default", + api_version="2024-01-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_security_settings_operations_async.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_security_settings_operations_async.py new file mode 100644 index 000000000000..0915cc0501fe --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_security_settings_operations_async.py @@ -0,0 +1,97 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.azurestackhci.aio import AzureStackHCIClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureStackHCISecuritySettingsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureStackHCIClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_clusters(self, resource_group): + response = self.client.security_settings.list_by_clusters( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-01-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.security_settings.get( + resource_group_name=resource_group.name, + cluster_name="str", + security_settings_name="default", + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.security_settings.begin_create_or_update( + resource_group_name=resource_group.name, + cluster_name="str", + resource={ + "id": "str", + "name": "str", + "provisioningState": "str", + "securedCoreComplianceAssignment": "str", + "securityComplianceStatus": { + "dataAtRestEncrypted": "str", + "dataInTransitProtected": "str", + "lastUpdated": "2020-02-20 00:00:00", + "securedCoreCompliance": "str", + "wdacCompliance": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + security_settings_name="default", + api_version="2024-01-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.security_settings.begin_delete( + resource_group_name=resource_group.name, + cluster_name="str", + security_settings_name="default", + api_version="2024-01-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_skus_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_skus_operations.py new file mode 100644 index 000000000000..f0686b065585 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_skus_operations.py @@ -0,0 +1,48 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.azurestackhci import AzureStackHCIClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureStackHCISkusOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureStackHCIClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_offer(self, resource_group): + response = self.client.skus.list_by_offer( + resource_group_name=resource_group.name, + cluster_name="str", + publisher_name="str", + offer_name="str", + api_version="2024-01-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.skus.get( + resource_group_name=resource_group.name, + cluster_name="str", + publisher_name="str", + offer_name="str", + sku_name="str", + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_skus_operations_async.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_skus_operations_async.py new file mode 100644 index 000000000000..4ef83dba7b12 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_skus_operations_async.py @@ -0,0 +1,49 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.azurestackhci.aio import AzureStackHCIClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureStackHCISkusOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureStackHCIClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_offer(self, resource_group): + response = self.client.skus.list_by_offer( + resource_group_name=resource_group.name, + cluster_name="str", + publisher_name="str", + offer_name="str", + api_version="2024-01-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.skus.get( + resource_group_name=resource_group.name, + cluster_name="str", + publisher_name="str", + offer_name="str", + sku_name="str", + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_storage_containers_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_storage_containers_operations.py new file mode 100644 index 000000000000..1abf2ae96ea1 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_storage_containers_operations.py @@ -0,0 +1,114 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.azurestackhci import AzureStackHCIClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureStackHCIStorageContainersOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureStackHCIClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.storage_containers.get( + resource_group_name=resource_group.name, + storage_container_name="str", + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.storage_containers.begin_create_or_update( + resource_group_name=resource_group.name, + storage_container_name="str", + storage_containers={ + "location": "str", + "extendedLocation": {"name": "str", "type": "str"}, + "id": "str", + "name": "str", + "path": "str", + "provisioningState": "str", + "status": { + "availableSizeMB": 0, + "containerSizeMB": 0, + "errorCode": "str", + "errorMessage": "str", + "provisioningStatus": {"operationId": "str", "status": "str"}, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2024-01-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.storage_containers.begin_delete( + resource_group_name=resource_group.name, + storage_container_name="str", + api_version="2024-01-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.storage_containers.begin_update( + resource_group_name=resource_group.name, + storage_container_name="str", + storage_containers={"tags": {"str": "str"}}, + api_version="2024-01-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.storage_containers.list( + resource_group_name=resource_group.name, + api_version="2024-01-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_all(self, resource_group): + response = self.client.storage_containers.list_all( + api_version="2024-01-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_storage_containers_operations_async.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_storage_containers_operations_async.py new file mode 100644 index 000000000000..c76300758ad6 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_storage_containers_operations_async.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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.azurestackhci.aio import AzureStackHCIClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureStackHCIStorageContainersOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureStackHCIClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.storage_containers.get( + resource_group_name=resource_group.name, + storage_container_name="str", + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.storage_containers.begin_create_or_update( + resource_group_name=resource_group.name, + storage_container_name="str", + storage_containers={ + "location": "str", + "extendedLocation": {"name": "str", "type": "str"}, + "id": "str", + "name": "str", + "path": "str", + "provisioningState": "str", + "status": { + "availableSizeMB": 0, + "containerSizeMB": 0, + "errorCode": "str", + "errorMessage": "str", + "provisioningStatus": {"operationId": "str", "status": "str"}, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2024-01-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.storage_containers.begin_delete( + resource_group_name=resource_group.name, + storage_container_name="str", + api_version="2024-01-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.storage_containers.begin_update( + resource_group_name=resource_group.name, + storage_container_name="str", + storage_containers={"tags": {"str": "str"}}, + api_version="2024-01-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.storage_containers.list( + resource_group_name=resource_group.name, + api_version="2024-01-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_all(self, resource_group): + response = self.client.storage_containers.list_all( + api_version="2024-01-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_update_runs_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_update_runs_operations.py new file mode 100644 index 000000000000..54eb978dbdd6 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_update_runs_operations.py @@ -0,0 +1,111 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.azurestackhci import AzureStackHCIClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureStackHCIUpdateRunsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureStackHCIClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.update_runs.list( + resource_group_name=resource_group.name, + cluster_name="str", + update_name="str", + api_version="2024-01-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.update_runs.begin_delete( + resource_group_name=resource_group.name, + cluster_name="str", + update_name="str", + update_run_name="str", + api_version="2024-01-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_put(self, resource_group): + response = self.client.update_runs.put( + resource_group_name=resource_group.name, + cluster_name="str", + update_name="str", + update_run_name="str", + update_runs_properties={ + "description": "str", + "duration": "str", + "endTimeUtc": "2020-02-20 00:00:00", + "errorMessage": "str", + "id": "str", + "lastUpdatedTime": "2020-02-20 00:00:00", + "lastUpdatedTimeUtc": "2020-02-20 00:00:00", + "location": "str", + "name": "str", + "provisioningState": "str", + "startTimeUtc": "2020-02-20 00:00:00", + "state": "str", + "status": "str", + "steps": [ + { + "description": "str", + "endTimeUtc": "2020-02-20 00:00:00", + "errorMessage": "str", + "lastUpdatedTimeUtc": "2020-02-20 00:00:00", + "name": "str", + "startTimeUtc": "2020-02-20 00:00:00", + "status": "str", + "steps": [...], + } + ], + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "timeStarted": "2020-02-20 00:00:00", + "type": "str", + }, + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.update_runs.get( + resource_group_name=resource_group.name, + cluster_name="str", + update_name="str", + update_run_name="str", + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_update_runs_operations_async.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_update_runs_operations_async.py new file mode 100644 index 000000000000..0ac4e86df93a --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_update_runs_operations_async.py @@ -0,0 +1,114 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.azurestackhci.aio import AzureStackHCIClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureStackHCIUpdateRunsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureStackHCIClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.update_runs.list( + resource_group_name=resource_group.name, + cluster_name="str", + update_name="str", + api_version="2024-01-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.update_runs.begin_delete( + resource_group_name=resource_group.name, + cluster_name="str", + update_name="str", + update_run_name="str", + api_version="2024-01-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_put(self, resource_group): + response = await self.client.update_runs.put( + resource_group_name=resource_group.name, + cluster_name="str", + update_name="str", + update_run_name="str", + update_runs_properties={ + "description": "str", + "duration": "str", + "endTimeUtc": "2020-02-20 00:00:00", + "errorMessage": "str", + "id": "str", + "lastUpdatedTime": "2020-02-20 00:00:00", + "lastUpdatedTimeUtc": "2020-02-20 00:00:00", + "location": "str", + "name": "str", + "provisioningState": "str", + "startTimeUtc": "2020-02-20 00:00:00", + "state": "str", + "status": "str", + "steps": [ + { + "description": "str", + "endTimeUtc": "2020-02-20 00:00:00", + "errorMessage": "str", + "lastUpdatedTimeUtc": "2020-02-20 00:00:00", + "name": "str", + "startTimeUtc": "2020-02-20 00:00:00", + "status": "str", + "steps": [...], + } + ], + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "timeStarted": "2020-02-20 00:00:00", + "type": "str", + }, + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.update_runs.get( + resource_group_name=resource_group.name, + cluster_name="str", + update_name="str", + update_run_name="str", + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_update_summaries_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_update_summaries_operations.py new file mode 100644 index 000000000000..721507d70d5d --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_update_summaries_operations.py @@ -0,0 +1,108 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.azurestackhci import AzureStackHCIClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureStackHCIUpdateSummariesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureStackHCIClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.update_summaries.list( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-01-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.update_summaries.begin_delete( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-01-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_put(self, resource_group): + response = self.client.update_summaries.put( + resource_group_name=resource_group.name, + cluster_name="str", + update_location_properties={ + "currentVersion": "str", + "hardwareModel": "str", + "healthCheckDate": "2020-02-20 00:00:00", + "healthCheckResult": [ + { + "additionalData": "str", + "description": "str", + "displayName": "str", + "healthCheckSource": "str", + "name": "str", + "remediation": "str", + "severity": "str", + "status": "str", + "tags": {"key": "str", "value": "str"}, + "targetResourceID": "str", + "targetResourceName": "str", + "timestamp": "2020-02-20 00:00:00", + "title": "str", + } + ], + "healthState": "str", + "id": "str", + "lastChecked": "2020-02-20 00:00:00", + "lastUpdated": "2020-02-20 00:00:00", + "location": "str", + "name": "str", + "oemFamily": "str", + "packageVersions": [{"lastUpdated": "2020-02-20 00:00:00", "packageType": "str", "version": "str"}], + "provisioningState": "str", + "state": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.update_summaries.get( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_update_summaries_operations_async.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_update_summaries_operations_async.py new file mode 100644 index 000000000000..88aecba37093 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_update_summaries_operations_async.py @@ -0,0 +1,111 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.azurestackhci.aio import AzureStackHCIClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureStackHCIUpdateSummariesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureStackHCIClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.update_summaries.list( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-01-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.update_summaries.begin_delete( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-01-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_put(self, resource_group): + response = await self.client.update_summaries.put( + resource_group_name=resource_group.name, + cluster_name="str", + update_location_properties={ + "currentVersion": "str", + "hardwareModel": "str", + "healthCheckDate": "2020-02-20 00:00:00", + "healthCheckResult": [ + { + "additionalData": "str", + "description": "str", + "displayName": "str", + "healthCheckSource": "str", + "name": "str", + "remediation": "str", + "severity": "str", + "status": "str", + "tags": {"key": "str", "value": "str"}, + "targetResourceID": "str", + "targetResourceName": "str", + "timestamp": "2020-02-20 00:00:00", + "title": "str", + } + ], + "healthState": "str", + "id": "str", + "lastChecked": "2020-02-20 00:00:00", + "lastUpdated": "2020-02-20 00:00:00", + "location": "str", + "name": "str", + "oemFamily": "str", + "packageVersions": [{"lastUpdated": "2020-02-20 00:00:00", "packageType": "str", "version": "str"}], + "provisioningState": "str", + "state": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.update_summaries.get( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_updates_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_updates_operations.py new file mode 100644 index 000000000000..9de345b9d957 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_updates_operations.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. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.azurestackhci import AzureStackHCIClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureStackHCIUpdatesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureStackHCIClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_post(self, resource_group): + response = self.client.updates.begin_post( + resource_group_name=resource_group.name, + cluster_name="str", + update_name="str", + api_version="2024-01-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.updates.list( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-01-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.updates.begin_delete( + resource_group_name=resource_group.name, + cluster_name="str", + update_name="str", + api_version="2024-01-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_put(self, resource_group): + response = self.client.updates.put( + resource_group_name=resource_group.name, + cluster_name="str", + update_name="str", + update_properties={ + "availabilityType": "str", + "componentVersions": [{"lastUpdated": "2020-02-20 00:00:00", "packageType": "str", "version": "str"}], + "description": "str", + "displayName": "str", + "healthCheckDate": "2020-02-20 00:00:00", + "healthCheckResult": [ + { + "additionalData": "str", + "description": "str", + "displayName": "str", + "healthCheckSource": "str", + "name": "str", + "remediation": "str", + "severity": "str", + "status": "str", + "tags": {"key": "str", "value": "str"}, + "targetResourceID": "str", + "targetResourceName": "str", + "timestamp": "2020-02-20 00:00:00", + "title": "str", + } + ], + "healthState": "str", + "id": "str", + "installedDate": "2020-02-20 00:00:00", + "location": "str", + "name": "str", + "notifyMessage": "str", + "packagePath": "str", + "packageSizeInMb": 0.0, + "packageType": "str", + "prerequisites": [{"packageName": "str", "updateType": "str", "version": "str"}], + "progressPercentage": 0.0, + "provisioningState": "str", + "publisher": "str", + "rebootRequired": "str", + "releaseLink": "str", + "state": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + "version": "str", + }, + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.updates.get( + resource_group_name=resource_group.name, + cluster_name="str", + update_name="str", + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_updates_operations_async.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_updates_operations_async.py new file mode 100644 index 000000000000..8594b3875736 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_updates_operations_async.py @@ -0,0 +1,138 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.azurestackhci.aio import AzureStackHCIClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureStackHCIUpdatesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureStackHCIClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_post(self, resource_group): + response = await ( + await self.client.updates.begin_post( + resource_group_name=resource_group.name, + cluster_name="str", + update_name="str", + api_version="2024-01-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.updates.list( + resource_group_name=resource_group.name, + cluster_name="str", + api_version="2024-01-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.updates.begin_delete( + resource_group_name=resource_group.name, + cluster_name="str", + update_name="str", + api_version="2024-01-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_put(self, resource_group): + response = await self.client.updates.put( + resource_group_name=resource_group.name, + cluster_name="str", + update_name="str", + update_properties={ + "availabilityType": "str", + "componentVersions": [{"lastUpdated": "2020-02-20 00:00:00", "packageType": "str", "version": "str"}], + "description": "str", + "displayName": "str", + "healthCheckDate": "2020-02-20 00:00:00", + "healthCheckResult": [ + { + "additionalData": "str", + "description": "str", + "displayName": "str", + "healthCheckSource": "str", + "name": "str", + "remediation": "str", + "severity": "str", + "status": "str", + "tags": {"key": "str", "value": "str"}, + "targetResourceID": "str", + "targetResourceName": "str", + "timestamp": "2020-02-20 00:00:00", + "title": "str", + } + ], + "healthState": "str", + "id": "str", + "installedDate": "2020-02-20 00:00:00", + "location": "str", + "name": "str", + "notifyMessage": "str", + "packagePath": "str", + "packageSizeInMb": 0.0, + "packageType": "str", + "prerequisites": [{"packageName": "str", "updateType": "str", "version": "str"}], + "progressPercentage": 0.0, + "provisioningState": "str", + "publisher": "str", + "rebootRequired": "str", + "releaseLink": "str", + "state": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + "version": "str", + }, + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.updates.get( + resource_group_name=resource_group.name, + cluster_name="str", + update_name="str", + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_virtual_hard_disks_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_virtual_hard_disks_operations.py new file mode 100644 index 000000000000..499d309ed7ba --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_virtual_hard_disks_operations.py @@ -0,0 +1,119 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.azurestackhci import AzureStackHCIClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureStackHCIVirtualHardDisksOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureStackHCIClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.virtual_hard_disks.get( + resource_group_name=resource_group.name, + virtual_hard_disk_name="str", + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.virtual_hard_disks.begin_create_or_update( + resource_group_name=resource_group.name, + virtual_hard_disk_name="str", + virtual_hard_disks={ + "location": "str", + "blockSizeBytes": 0, + "containerId": "str", + "diskFileFormat": "str", + "diskSizeGB": 0, + "dynamic": bool, + "extendedLocation": {"name": "str", "type": "str"}, + "hyperVGeneration": "str", + "id": "str", + "logicalSectorBytes": 0, + "name": "str", + "physicalSectorBytes": 0, + "provisioningState": "str", + "status": { + "errorCode": "str", + "errorMessage": "str", + "provisioningStatus": {"operationId": "str", "status": "str"}, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2024-01-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.virtual_hard_disks.begin_delete( + resource_group_name=resource_group.name, + virtual_hard_disk_name="str", + api_version="2024-01-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.virtual_hard_disks.begin_update( + resource_group_name=resource_group.name, + virtual_hard_disk_name="str", + virtual_hard_disks={"tags": {"str": "str"}}, + api_version="2024-01-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.virtual_hard_disks.list( + resource_group_name=resource_group.name, + api_version="2024-01-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_all(self, resource_group): + response = self.client.virtual_hard_disks.list_all( + api_version="2024-01-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_virtual_hard_disks_operations_async.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_virtual_hard_disks_operations_async.py new file mode 100644 index 000000000000..043ce061e2b3 --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_virtual_hard_disks_operations_async.py @@ -0,0 +1,126 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.azurestackhci.aio import AzureStackHCIClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureStackHCIVirtualHardDisksOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureStackHCIClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.virtual_hard_disks.get( + resource_group_name=resource_group.name, + virtual_hard_disk_name="str", + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.virtual_hard_disks.begin_create_or_update( + resource_group_name=resource_group.name, + virtual_hard_disk_name="str", + virtual_hard_disks={ + "location": "str", + "blockSizeBytes": 0, + "containerId": "str", + "diskFileFormat": "str", + "diskSizeGB": 0, + "dynamic": bool, + "extendedLocation": {"name": "str", "type": "str"}, + "hyperVGeneration": "str", + "id": "str", + "logicalSectorBytes": 0, + "name": "str", + "physicalSectorBytes": 0, + "provisioningState": "str", + "status": { + "errorCode": "str", + "errorMessage": "str", + "provisioningStatus": {"operationId": "str", "status": "str"}, + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "tags": {"str": "str"}, + "type": "str", + }, + api_version="2024-01-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.virtual_hard_disks.begin_delete( + resource_group_name=resource_group.name, + virtual_hard_disk_name="str", + api_version="2024-01-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.virtual_hard_disks.begin_update( + resource_group_name=resource_group.name, + virtual_hard_disk_name="str", + virtual_hard_disks={"tags": {"str": "str"}}, + api_version="2024-01-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.virtual_hard_disks.list( + resource_group_name=resource_group.name, + api_version="2024-01-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_all(self, resource_group): + response = self.client.virtual_hard_disks.list_all( + api_version="2024-01-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_virtual_machine_instances_operations.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_virtual_machine_instances_operations.py new file mode 100644 index 000000000000..09cdfe3b96aa --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_virtual_machine_instances_operations.py @@ -0,0 +1,210 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.azurestackhci import AzureStackHCIClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureStackHCIVirtualMachineInstancesOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureStackHCIClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.virtual_machine_instances.get( + resource_uri="str", + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.virtual_machine_instances.begin_create_or_update( + resource_uri="str", + virtual_machine_instance={ + "extendedLocation": {"name": "str", "type": "str"}, + "guestAgentInstallStatus": { + "agentVersion": "str", + "errorDetails": [ + { + "additionalInfo": [{"info": {}, "type": "str"}], + "code": "str", + "details": [...], + "message": "str", + "target": "str", + } + ], + "lastStatusChange": "2020-02-20 00:00:00", + "status": "str", + "vmUuid": "str", + }, + "hardwareProfile": { + "dynamicMemoryConfig": {"maximumMemoryMB": 0, "minimumMemoryMB": 0, "targetMemoryBuffer": 0}, + "memoryMB": 0, + "processors": 0, + "vmSize": "str", + }, + "httpProxyConfig": {"httpProxy": "str", "httpsProxy": "str", "noProxy": ["str"], "trustedCa": "str"}, + "id": "str", + "identity": {"principalId": "str", "tenantId": "str", "type": "SystemAssigned"}, + "instanceView": { + "vmAgent": { + "statuses": [ + { + "code": "str", + "displayStatus": "str", + "level": "str", + "message": "str", + "time": "2020-02-20 00:00:00", + } + ], + "vmConfigAgentVersion": "str", + } + }, + "name": "str", + "networkProfile": {"networkInterfaces": [{"id": "str"}]}, + "osProfile": { + "adminPassword": "str", + "adminUsername": "str", + "computerName": "str", + "linuxConfiguration": { + "disablePasswordAuthentication": bool, + "provisionVMAgent": True, + "provisionVMConfigAgent": True, + "ssh": {"publicKeys": [{"keyData": "str", "path": "str"}]}, + }, + "windowsConfiguration": { + "enableAutomaticUpdates": bool, + "provisionVMAgent": True, + "provisionVMConfigAgent": True, + "ssh": {"publicKeys": [{"keyData": "str", "path": "str"}]}, + "timeZone": "str", + }, + }, + "provisioningState": "str", + "resourceUid": "str", + "securityProfile": { + "enableTPM": False, + "securityType": "str", + "uefiSettings": {"secureBootEnabled": False}, + }, + "status": { + "errorCode": "str", + "errorMessage": "str", + "powerState": "str", + "provisioningStatus": {"operationId": "str", "status": "str"}, + }, + "storageProfile": { + "dataDisks": [{"id": "str"}], + "imageReference": {"id": "str"}, + "osDisk": {"id": "str", "osType": "str"}, + "vmConfigStoragePathId": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + "vmId": "str", + }, + api_version="2024-01-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.virtual_machine_instances.begin_delete( + resource_uri="str", + api_version="2024-01-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.virtual_machine_instances.begin_update( + resource_uri="str", + virtual_machine_instance={ + "identity": {"principalId": "str", "tenantId": "str", "type": "SystemAssigned"}, + "properties": { + "hardwareProfile": {"memoryMB": 0, "processors": 0, "vmSize": "str"}, + "networkProfile": {"networkInterfaces": [{"id": "str"}]}, + "osProfile": { + "computerName": "str", + "linuxConfiguration": {"provisionVMAgent": bool, "provisionVMConfigAgent": bool}, + "windowsConfiguration": {"provisionVMAgent": bool, "provisionVMConfigAgent": bool}, + }, + "storageProfile": {"dataDisks": [{"id": "str"}]}, + }, + }, + api_version="2024-01-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_start(self, resource_group): + response = self.client.virtual_machine_instances.begin_start( + resource_uri="str", + api_version="2024-01-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_stop(self, resource_group): + response = self.client.virtual_machine_instances.begin_stop( + resource_uri="str", + api_version="2024-01-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_restart(self, resource_group): + response = self.client.virtual_machine_instances.begin_restart( + resource_uri="str", + api_version="2024-01-01", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.virtual_machine_instances.list( + resource_uri="str", + api_version="2024-01-01", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_virtual_machine_instances_operations_async.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_virtual_machine_instances_operations_async.py new file mode 100644 index 000000000000..190116c5e9ae --- /dev/null +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/generated_tests/test_azure_stack_hci_virtual_machine_instances_operations_async.py @@ -0,0 +1,228 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.azurestackhci.aio import AzureStackHCIClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAzureStackHCIVirtualMachineInstancesOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AzureStackHCIClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.virtual_machine_instances.get( + resource_uri="str", + api_version="2024-01-01", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.virtual_machine_instances.begin_create_or_update( + resource_uri="str", + virtual_machine_instance={ + "extendedLocation": {"name": "str", "type": "str"}, + "guestAgentInstallStatus": { + "agentVersion": "str", + "errorDetails": [ + { + "additionalInfo": [{"info": {}, "type": "str"}], + "code": "str", + "details": [...], + "message": "str", + "target": "str", + } + ], + "lastStatusChange": "2020-02-20 00:00:00", + "status": "str", + "vmUuid": "str", + }, + "hardwareProfile": { + "dynamicMemoryConfig": {"maximumMemoryMB": 0, "minimumMemoryMB": 0, "targetMemoryBuffer": 0}, + "memoryMB": 0, + "processors": 0, + "vmSize": "str", + }, + "httpProxyConfig": { + "httpProxy": "str", + "httpsProxy": "str", + "noProxy": ["str"], + "trustedCa": "str", + }, + "id": "str", + "identity": {"principalId": "str", "tenantId": "str", "type": "SystemAssigned"}, + "instanceView": { + "vmAgent": { + "statuses": [ + { + "code": "str", + "displayStatus": "str", + "level": "str", + "message": "str", + "time": "2020-02-20 00:00:00", + } + ], + "vmConfigAgentVersion": "str", + } + }, + "name": "str", + "networkProfile": {"networkInterfaces": [{"id": "str"}]}, + "osProfile": { + "adminPassword": "str", + "adminUsername": "str", + "computerName": "str", + "linuxConfiguration": { + "disablePasswordAuthentication": bool, + "provisionVMAgent": True, + "provisionVMConfigAgent": True, + "ssh": {"publicKeys": [{"keyData": "str", "path": "str"}]}, + }, + "windowsConfiguration": { + "enableAutomaticUpdates": bool, + "provisionVMAgent": True, + "provisionVMConfigAgent": True, + "ssh": {"publicKeys": [{"keyData": "str", "path": "str"}]}, + "timeZone": "str", + }, + }, + "provisioningState": "str", + "resourceUid": "str", + "securityProfile": { + "enableTPM": False, + "securityType": "str", + "uefiSettings": {"secureBootEnabled": False}, + }, + "status": { + "errorCode": "str", + "errorMessage": "str", + "powerState": "str", + "provisioningStatus": {"operationId": "str", "status": "str"}, + }, + "storageProfile": { + "dataDisks": [{"id": "str"}], + "imageReference": {"id": "str"}, + "osDisk": {"id": "str", "osType": "str"}, + "vmConfigStoragePathId": "str", + }, + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + "vmId": "str", + }, + api_version="2024-01-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.virtual_machine_instances.begin_delete( + resource_uri="str", + api_version="2024-01-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.virtual_machine_instances.begin_update( + resource_uri="str", + virtual_machine_instance={ + "identity": {"principalId": "str", "tenantId": "str", "type": "SystemAssigned"}, + "properties": { + "hardwareProfile": {"memoryMB": 0, "processors": 0, "vmSize": "str"}, + "networkProfile": {"networkInterfaces": [{"id": "str"}]}, + "osProfile": { + "computerName": "str", + "linuxConfiguration": {"provisionVMAgent": bool, "provisionVMConfigAgent": bool}, + "windowsConfiguration": {"provisionVMAgent": bool, "provisionVMConfigAgent": bool}, + }, + "storageProfile": {"dataDisks": [{"id": "str"}]}, + }, + }, + api_version="2024-01-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_start(self, resource_group): + response = await ( + await self.client.virtual_machine_instances.begin_start( + resource_uri="str", + api_version="2024-01-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_stop(self, resource_group): + response = await ( + await self.client.virtual_machine_instances.begin_stop( + resource_uri="str", + api_version="2024-01-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_restart(self, resource_group): + response = await ( + await self.client.virtual_machine_instances.begin_restart( + resource_uri="str", + api_version="2024-01-01", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.virtual_machine_instances.list( + resource_uri="str", + api_version="2024-01-01", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/azurestackhci/azure-mgmt-azurestackhci/setup.py b/sdk/azurestackhci/azure-mgmt-azurestackhci/setup.py index 68605c29d62f..17bb6ae831b0 100644 --- a/sdk/azurestackhci/azure-mgmt-azurestackhci/setup.py +++ b/sdk/azurestackhci/azure-mgmt-azurestackhci/setup.py @@ -53,11 +53,11 @@ "Programming Language :: Python", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "License :: OSI Approved :: MIT License", ], zip_safe=False, @@ -74,10 +74,10 @@ "pytyped": ["py.typed"], }, install_requires=[ - "isodate<1.0.0,>=0.6.1", - "azure-common~=1.1", - "azure-mgmt-core>=1.3.2,<2.0.0", - "typing-extensions>=4.3.0; python_version<'3.8.0'", + "isodate>=0.6.1", + "typing-extensions>=4.6.0", + "azure-common>=1.1", + "azure-mgmt-core>=1.3.2", ], - python_requires=">=3.7", + python_requires=">=3.8", )