From f195ebc1d998c6ee952f5de524ac034b313d3510 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Mon, 13 Feb 2023 08:41:50 +0000 Subject: [PATCH] CodeGen from PR 22575 in Azure/azure-rest-api-specs Merge 58e200d1fe0765b36378c106af0c1d1cbf012fcc into f1180941e238bc99ac71f9535ecd126bb8b77d8f --- sdk/monitor/azure-mgmt-monitor/_meta.json | 8 +- .../create_or_update_autoscale_setting.py | 160 +++ .../delete_autoscale_setting.py | 41 + .../get_autoscale_setting.py | 41 + .../get_predictive_metric.py | 48 + .../list_autoscale_setting.py | 41 + .../list_autoscale_setting_by_subscription.py | 39 + .../patch_autoscale_setting.py | 159 +++ .../azure/mgmt/monitor/_configuration.py | 6 +- .../monitor/_monitor_management_client.py | 13 +- .../azure/mgmt/monitor/_serialization.py | 682 ++++++----- .../azure/mgmt/monitor/aio/_configuration.py | 2 +- .../monitor/aio/_monitor_management_client.py | 9 +- .../mgmt/monitor/v2015_04_01/__init__.py | 6 +- .../monitor/v2015_04_01/_configuration.py | 5 +- .../mgmt/monitor/v2015_04_01/_metadata.json | 30 +- .../v2015_04_01/_monitor_management_client.py | 13 +- .../azure/mgmt/monitor/v2015_04_01/_vendor.py | 5 +- .../mgmt/monitor/v2015_04_01/_version.py | 2 +- .../mgmt/monitor/v2015_04_01/aio/__init__.py | 6 +- .../aio/_monitor_management_client.py | 6 +- .../v2015_04_01/aio/operations/__init__.py | 2 +- .../operations/_activity_logs_operations.py | 19 +- .../aio/operations/_alert_rules_operations.py | 103 +- .../_autoscale_settings_operations.py | 101 +- .../_event_categories_operations.py | 19 +- .../v2015_04_01/aio/operations/_operations.py | 15 +- .../_tenant_activity_logs_operations.py | 19 +- .../monitor/v2015_04_01/models/__init__.py | 2 +- .../monitor/v2015_04_01/models/_models_py3.py | 191 +-- .../v2015_04_01/operations/__init__.py | 2 +- .../operations/_activity_logs_operations.py | 23 +- .../operations/_alert_rules_operations.py | 131 +- .../_autoscale_settings_operations.py | 129 +- .../_event_categories_operations.py | 21 +- .../v2015_04_01/operations/_operations.py | 17 +- .../_tenant_activity_logs_operations.py | 21 +- .../mgmt/monitor/v2015_07_01/__init__.py | 6 +- .../monitor/v2015_07_01/_configuration.py | 5 +- .../mgmt/monitor/v2015_07_01/_metadata.json | 30 +- .../v2015_07_01/_monitor_management_client.py | 13 +- .../azure/mgmt/monitor/v2015_07_01/_vendor.py | 5 +- .../mgmt/monitor/v2015_07_01/_version.py | 2 +- .../mgmt/monitor/v2015_07_01/aio/__init__.py | 6 +- .../aio/_monitor_management_client.py | 6 +- .../v2015_07_01/aio/operations/__init__.py | 2 +- .../aio/operations/_alert_rules_operations.py | 103 +- .../_metric_definitions_operations.py | 19 +- .../v2015_07_01/aio/operations/_operations.py | 15 +- ..._service_diagnostic_settings_operations.py | 31 +- .../monitor/v2015_07_01/models/__init__.py | 2 +- .../monitor/v2015_07_01/models/_models_py3.py | 170 +-- .../v2015_07_01/operations/__init__.py | 2 +- .../operations/_alert_rules_operations.py | 131 +- .../_metric_definitions_operations.py | 23 +- .../v2015_07_01/operations/_operations.py | 17 +- ..._service_diagnostic_settings_operations.py | 41 +- .../mgmt/monitor/v2016_03_01/__init__.py | 6 +- .../monitor/v2016_03_01/_configuration.py | 13 +- .../mgmt/monitor/v2016_03_01/_metadata.json | 30 +- .../v2016_03_01/_monitor_management_client.py | 13 +- .../azure/mgmt/monitor/v2016_03_01/_vendor.py | 5 +- .../mgmt/monitor/v2016_03_01/_version.py | 2 +- .../mgmt/monitor/v2016_03_01/aio/__init__.py | 6 +- .../monitor/v2016_03_01/aio/_configuration.py | 8 +- .../aio/_monitor_management_client.py | 6 +- .../v2016_03_01/aio/operations/__init__.py | 2 +- .../_alert_rule_incidents_operations.py | 48 +- .../aio/operations/_alert_rules_operations.py | 131 +- .../operations/_log_profiles_operations.py | 92 +- .../_metric_definitions_operations.py | 34 +- .../monitor/v2016_03_01/models/__init__.py | 2 +- .../monitor/v2016_03_01/models/_models_py3.py | 121 +- .../v2016_03_01/operations/__init__.py | 2 +- .../_alert_rule_incidents_operations.py | 56 +- .../operations/_alert_rules_operations.py | 159 ++- .../operations/_log_profiles_operations.py | 116 +- .../_metric_definitions_operations.py | 38 +- .../mgmt/monitor/v2016_09_01/__init__.py | 6 +- .../monitor/v2016_09_01/_configuration.py | 13 +- .../mgmt/monitor/v2016_09_01/_metadata.json | 27 +- .../v2016_09_01/_monitor_management_client.py | 13 +- .../azure/mgmt/monitor/v2016_09_01/_vendor.py | 5 +- .../mgmt/monitor/v2016_09_01/_version.py | 2 +- .../mgmt/monitor/v2016_09_01/aio/__init__.py | 6 +- .../monitor/v2016_09_01/aio/_configuration.py | 8 +- .../aio/_monitor_management_client.py | 6 +- .../v2016_09_01/aio/operations/__init__.py | 2 +- .../aio/operations/_metrics_operations.py | 34 +- ..._service_diagnostic_settings_operations.py | 45 +- .../monitor/v2016_09_01/models/__init__.py | 2 +- .../monitor/v2016_09_01/models/_models_py3.py | 36 +- .../v2016_09_01/operations/__init__.py | 2 +- .../operations/_metrics_operations.py | 38 +- ..._service_diagnostic_settings_operations.py | 61 +- .../monitor/v2017_03_01_preview/__init__.py | 6 +- .../v2017_03_01_preview/_configuration.py | 13 +- .../v2017_03_01_preview/_metadata.json | 30 +- .../_monitor_management_client.py | 13 +- .../monitor/v2017_03_01_preview/_vendor.py | 5 +- .../monitor/v2017_03_01_preview/_version.py | 2 +- .../v2017_03_01_preview/aio/__init__.py | 6 +- .../v2017_03_01_preview/aio/_configuration.py | 8 +- .../aio/_monitor_management_client.py | 6 +- .../aio/operations/__init__.py | 2 +- .../_activity_log_alerts_operations.py | 139 ++- .../v2017_03_01_preview/models/__init__.py | 2 +- .../v2017_03_01_preview/models/_models_py3.py | 28 +- .../operations/__init__.py | 2 +- .../_activity_log_alerts_operations.py | 179 ++- .../mgmt/monitor/v2017_04_01/__init__.py | 6 +- .../monitor/v2017_04_01/_configuration.py | 13 +- .../mgmt/monitor/v2017_04_01/_metadata.json | 30 +- .../v2017_04_01/_monitor_management_client.py | 13 +- .../azure/mgmt/monitor/v2017_04_01/_vendor.py | 5 +- .../mgmt/monitor/v2017_04_01/_version.py | 2 +- .../mgmt/monitor/v2017_04_01/aio/__init__.py | 6 +- .../monitor/v2017_04_01/aio/_configuration.py | 8 +- .../aio/_monitor_management_client.py | 6 +- .../v2017_04_01/aio/operations/__init__.py | 2 +- .../operations/_action_groups_operations.py | 145 ++- .../_activity_log_alerts_operations.py | 127 +- .../monitor/v2017_04_01/models/__init__.py | 2 +- .../monitor/v2017_04_01/models/_models_py3.py | 60 +- .../v2017_04_01/operations/__init__.py | 2 +- .../operations/_action_groups_operations.py | 179 +-- .../_activity_log_alerts_operations.py | 155 ++- .../monitor/v2017_05_01_preview/__init__.py | 6 +- .../v2017_05_01_preview/_configuration.py | 13 +- .../v2017_05_01_preview/_metadata.json | 30 +- .../_monitor_management_client.py | 13 +- .../monitor/v2017_05_01_preview/_vendor.py | 5 +- .../monitor/v2017_05_01_preview/_version.py | 2 +- .../v2017_05_01_preview/aio/__init__.py | 6 +- .../v2017_05_01_preview/aio/_configuration.py | 8 +- .../aio/_monitor_management_client.py | 6 +- .../aio/operations/__init__.py | 2 +- ...diagnostic_settings_category_operations.py | 29 +- .../_diagnostic_settings_operations.py | 59 +- .../_metric_definitions_operations.py | 36 +- .../aio/operations/_metrics_operations.py | 17 +- ...cription_diagnostic_settings_operations.py | 61 +- .../v2017_05_01_preview/models/__init__.py | 2 +- .../v2017_05_01_preview/models/_models_py3.py | 75 +- .../operations/__init__.py | 2 +- ...diagnostic_settings_category_operations.py | 41 +- .../_diagnostic_settings_operations.py | 85 +- .../_metric_definitions_operations.py | 42 +- .../operations/_metrics_operations.py | 23 +- ...cription_diagnostic_settings_operations.py | 87 +- .../monitor/v2017_12_01_preview/__init__.py | 6 +- .../v2017_12_01_preview/_configuration.py | 13 +- .../v2017_12_01_preview/_metadata.json | 27 +- .../_monitor_management_client.py | 13 +- .../monitor/v2017_12_01_preview/_vendor.py | 5 +- .../monitor/v2017_12_01_preview/_version.py | 2 +- .../v2017_12_01_preview/aio/__init__.py | 6 +- .../v2017_12_01_preview/aio/_configuration.py | 8 +- .../aio/_monitor_management_client.py | 6 +- .../aio/operations/__init__.py | 2 +- .../_metric_namespaces_operations.py | 36 +- .../v2017_12_01_preview/models/__init__.py | 2 +- .../v2017_12_01_preview/models/_models_py3.py | 12 +- .../operations/__init__.py | 2 +- .../_metric_namespaces_operations.py | 42 +- .../mgmt/monitor/v2018_01_01/__init__.py | 6 +- .../monitor/v2018_01_01/_configuration.py | 13 +- .../mgmt/monitor/v2018_01_01/_metadata.json | 27 +- .../v2018_01_01/_monitor_management_client.py | 13 +- .../azure/mgmt/monitor/v2018_01_01/_vendor.py | 5 +- .../mgmt/monitor/v2018_01_01/_version.py | 2 +- .../mgmt/monitor/v2018_01_01/aio/__init__.py | 6 +- .../monitor/v2018_01_01/aio/_configuration.py | 8 +- .../aio/_monitor_management_client.py | 6 +- .../v2018_01_01/aio/operations/__init__.py | 2 +- .../_metric_definitions_operations.py | 34 +- .../aio/operations/_metrics_operations.py | 15 +- .../monitor/v2018_01_01/models/__init__.py | 2 +- .../monitor/v2018_01_01/models/_models_py3.py | 39 +- .../v2018_01_01/operations/__init__.py | 2 +- .../_metric_definitions_operations.py | 38 +- .../operations/_metrics_operations.py | 19 +- .../mgmt/monitor/v2018_03_01/__init__.py | 6 +- .../monitor/v2018_03_01/_configuration.py | 13 +- .../mgmt/monitor/v2018_03_01/_metadata.json | 30 +- .../v2018_03_01/_monitor_management_client.py | 13 +- .../azure/mgmt/monitor/v2018_03_01/_vendor.py | 5 +- .../mgmt/monitor/v2018_03_01/_version.py | 2 +- .../mgmt/monitor/v2018_03_01/aio/__init__.py | 6 +- .../monitor/v2018_03_01/aio/_configuration.py | 8 +- .../aio/_monitor_management_client.py | 6 +- .../v2018_03_01/aio/operations/__init__.py | 2 +- .../operations/_action_groups_operations.py | 145 ++- .../operations/_metric_alerts_operations.py | 123 +- .../_metric_alerts_status_operations.py | 29 +- .../monitor/v2018_03_01/models/__init__.py | 2 +- .../monitor/v2018_03_01/models/_models_py3.py | 128 +- .../v2018_03_01/operations/__init__.py | 2 +- .../operations/_action_groups_operations.py | 179 +-- .../operations/_metric_alerts_operations.py | 151 ++- .../_metric_alerts_status_operations.py | 37 +- .../mgmt/monitor/v2018_04_16/__init__.py | 6 +- .../monitor/v2018_04_16/_configuration.py | 13 +- .../mgmt/monitor/v2018_04_16/_metadata.json | 30 +- .../v2018_04_16/_monitor_management_client.py | 13 +- .../azure/mgmt/monitor/v2018_04_16/_vendor.py | 5 +- .../mgmt/monitor/v2018_04_16/_version.py | 2 +- .../mgmt/monitor/v2018_04_16/aio/__init__.py | 6 +- .../monitor/v2018_04_16/aio/_configuration.py | 8 +- .../aio/_monitor_management_client.py | 6 +- .../v2018_04_16/aio/operations/__init__.py | 2 +- .../_scheduled_query_rules_operations.py | 129 +- .../monitor/v2018_04_16/models/__init__.py | 2 +- .../monitor/v2018_04_16/models/_models_py3.py | 58 +- .../v2018_04_16/operations/__init__.py | 2 +- .../_scheduled_query_rules_operations.py | 157 ++- .../monitor/v2018_06_01_preview/__init__.py | 6 +- .../v2018_06_01_preview/_configuration.py | 13 +- .../v2018_06_01_preview/_metadata.json | 30 +- .../_monitor_management_client.py | 13 +- .../monitor/v2018_06_01_preview/_vendor.py | 5 +- .../monitor/v2018_06_01_preview/_version.py | 2 +- .../v2018_06_01_preview/aio/__init__.py | 6 +- .../v2018_06_01_preview/aio/_configuration.py | 8 +- .../aio/_monitor_management_client.py | 6 +- .../aio/operations/__init__.py | 2 +- ...nostics_settings_association_operations.py | 139 ++- .../_guest_diagnostics_settings_operations.py | 142 ++- .../v2018_06_01_preview/models/__init__.py | 2 +- .../v2018_06_01_preview/models/_models_py3.py | 70 +- .../operations/__init__.py | 2 +- ...nostics_settings_association_operations.py | 179 ++- .../_guest_diagnostics_settings_operations.py | 182 ++- .../mgmt/monitor/v2018_09_01/__init__.py | 6 +- .../monitor/v2018_09_01/_configuration.py | 13 +- .../mgmt/monitor/v2018_09_01/_metadata.json | 30 +- .../v2018_09_01/_monitor_management_client.py | 13 +- .../azure/mgmt/monitor/v2018_09_01/_vendor.py | 5 +- .../mgmt/monitor/v2018_09_01/_version.py | 2 +- .../mgmt/monitor/v2018_09_01/aio/__init__.py | 6 +- .../monitor/v2018_09_01/aio/_configuration.py | 8 +- .../aio/_monitor_management_client.py | 6 +- .../v2018_09_01/aio/operations/__init__.py | 2 +- .../operations/_action_groups_operations.py | 145 ++- .../aio/operations/_baselines_operations.py | 34 +- .../monitor/v2018_09_01/models/__init__.py | 2 +- .../monitor/v2018_09_01/models/_models_py3.py | 68 +- .../v2018_09_01/operations/__init__.py | 2 +- .../operations/_action_groups_operations.py | 179 +-- .../operations/_baselines_operations.py | 38 +- .../monitor/v2018_11_27_preview/__init__.py | 6 +- .../v2018_11_27_preview/_configuration.py | 13 +- .../v2018_11_27_preview/_metadata.json | 27 +- .../_monitor_management_client.py | 13 +- .../monitor/v2018_11_27_preview/_vendor.py | 5 +- .../monitor/v2018_11_27_preview/_version.py | 2 +- .../v2018_11_27_preview/aio/__init__.py | 6 +- .../v2018_11_27_preview/aio/_configuration.py | 8 +- .../aio/_monitor_management_client.py | 6 +- .../aio/operations/__init__.py | 2 +- .../aio/operations/_vm_insights_operations.py | 19 +- .../v2018_11_27_preview/models/__init__.py | 2 +- .../v2018_11_27_preview/models/_models_py3.py | 18 +- .../operations/__init__.py | 2 +- .../operations/_vm_insights_operations.py | 25 +- .../mgmt/monitor/v2019_03_01/__init__.py | 6 +- .../monitor/v2019_03_01/_configuration.py | 13 +- .../mgmt/monitor/v2019_03_01/_metadata.json | 30 +- .../v2019_03_01/_monitor_management_client.py | 13 +- .../azure/mgmt/monitor/v2019_03_01/_vendor.py | 5 +- .../mgmt/monitor/v2019_03_01/_version.py | 2 +- .../mgmt/monitor/v2019_03_01/aio/__init__.py | 6 +- .../monitor/v2019_03_01/aio/_configuration.py | 8 +- .../aio/_monitor_management_client.py | 6 +- .../v2019_03_01/aio/operations/__init__.py | 2 +- .../operations/_action_groups_operations.py | 145 ++- .../aio/operations/_baselines_operations.py | 34 +- .../monitor/v2019_03_01/models/__init__.py | 2 +- .../monitor/v2019_03_01/models/_models_py3.py | 68 +- .../v2019_03_01/operations/__init__.py | 2 +- .../operations/_action_groups_operations.py | 179 +-- .../operations/_baselines_operations.py | 38 +- .../mgmt/monitor/v2019_06_01/__init__.py | 6 +- .../monitor/v2019_06_01/_configuration.py | 13 +- .../mgmt/monitor/v2019_06_01/_metadata.json | 30 +- .../v2019_06_01/_monitor_management_client.py | 13 +- .../azure/mgmt/monitor/v2019_06_01/_vendor.py | 5 +- .../mgmt/monitor/v2019_06_01/_version.py | 2 +- .../mgmt/monitor/v2019_06_01/aio/__init__.py | 6 +- .../monitor/v2019_06_01/aio/_configuration.py | 8 +- .../aio/_monitor_management_client.py | 6 +- .../v2019_06_01/aio/operations/__init__.py | 2 +- .../operations/_action_groups_operations.py | 145 ++- .../monitor/v2019_06_01/models/__init__.py | 2 +- .../monitor/v2019_06_01/models/_models_py3.py | 56 +- .../v2019_06_01/operations/__init__.py | 2 +- .../operations/_action_groups_operations.py | 179 +-- .../mgmt/monitor/v2019_10_17/__init__.py | 6 +- .../monitor/v2019_10_17/_configuration.py | 13 +- .../mgmt/monitor/v2019_10_17/_metadata.json | 30 +- .../v2019_10_17/_monitor_management_client.py | 13 +- .../azure/mgmt/monitor/v2019_10_17/_vendor.py | 5 +- .../mgmt/monitor/v2019_10_17/_version.py | 2 +- .../mgmt/monitor/v2019_10_17/aio/__init__.py | 6 +- .../monitor/v2019_10_17/aio/_configuration.py | 8 +- .../aio/_monitor_management_client.py | 6 +- .../v2019_10_17/aio/operations/__init__.py | 2 +- ...private_endpoint_connections_operations.py | 124 +- .../_private_link_resources_operations.py | 52 +- ..._link_scope_operation_status_operations.py | 19 +- ...rivate_link_scoped_resources_operations.py | 124 +- .../_private_link_scopes_operations.py | 154 ++- .../monitor/v2019_10_17/models/__init__.py | 2 +- .../monitor/v2019_10_17/models/_models_py3.py | 45 +- .../v2019_10_17/operations/__init__.py | 2 +- ...private_endpoint_connections_operations.py | 150 ++- .../_private_link_resources_operations.py | 64 +- ..._link_scope_operation_status_operations.py | 25 +- ...rivate_link_scoped_resources_operations.py | 150 ++- .../_private_link_scopes_operations.py | 194 +-- .../monitor/v2019_11_01_preview/__init__.py | 6 +- .../v2019_11_01_preview/_configuration.py | 13 +- .../v2019_11_01_preview/_metadata.json | 30 +- .../_monitor_management_client.py | 13 +- .../monitor/v2019_11_01_preview/_vendor.py | 5 +- .../monitor/v2019_11_01_preview/_version.py | 2 +- .../v2019_11_01_preview/aio/__init__.py | 6 +- .../v2019_11_01_preview/aio/_configuration.py | 8 +- .../aio/_monitor_management_client.py | 6 +- .../aio/operations/__init__.py | 2 +- ...collection_rule_associations_operations.py | 118 +- .../_data_collection_rules_operations.py | 139 ++- .../v2019_11_01_preview/models/__init__.py | 2 +- .../v2019_11_01_preview/models/_models_py3.py | 245 ++-- .../operations/__init__.py | 2 +- ...collection_rule_associations_operations.py | 150 ++- .../_data_collection_rules_operations.py | 179 ++- .../monitor/v2020_01_01_preview/__init__.py | 6 +- .../v2020_01_01_preview/_configuration.py | 13 +- .../v2020_01_01_preview/_metadata.json | 27 +- .../_monitor_management_client.py | 13 +- .../monitor/v2020_01_01_preview/_vendor.py | 5 +- .../monitor/v2020_01_01_preview/_version.py | 2 +- .../v2020_01_01_preview/aio/__init__.py | 6 +- .../v2020_01_01_preview/aio/_configuration.py | 8 +- .../aio/_monitor_management_client.py | 6 +- .../aio/operations/__init__.py | 2 +- ...nt_group_diagnostic_settings_operations.py | 86 +- .../v2020_01_01_preview/models/__init__.py | 2 +- .../v2020_01_01_preview/models/_models_py3.py | 20 +- .../operations/__init__.py | 2 +- ...nt_group_diagnostic_settings_operations.py | 112 +- .../monitor/v2020_05_01_preview/__init__.py | 6 +- .../v2020_05_01_preview/_configuration.py | 13 +- .../v2020_05_01_preview/_metadata.json | 30 +- .../_monitor_management_client.py | 13 +- .../monitor/v2020_05_01_preview/_vendor.py | 5 +- .../monitor/v2020_05_01_preview/_version.py | 2 +- .../v2020_05_01_preview/aio/__init__.py | 6 +- .../v2020_05_01_preview/aio/_configuration.py | 8 +- .../aio/_monitor_management_client.py | 6 +- .../aio/operations/__init__.py | 2 +- .../_scheduled_query_rules_operations.py | 141 ++- .../v2020_05_01_preview/models/__init__.py | 2 +- .../v2020_05_01_preview/models/_models_py3.py | 53 +- .../operations/__init__.py | 2 +- .../_scheduled_query_rules_operations.py | 181 ++- .../mgmt/monitor/v2020_10_01/__init__.py | 6 +- .../monitor/v2020_10_01/_configuration.py | 13 +- .../mgmt/monitor/v2020_10_01/_metadata.json | 30 +- .../v2020_10_01/_monitor_management_client.py | 13 +- .../azure/mgmt/monitor/v2020_10_01/_vendor.py | 5 +- .../mgmt/monitor/v2020_10_01/_version.py | 2 +- .../mgmt/monitor/v2020_10_01/aio/__init__.py | 6 +- .../monitor/v2020_10_01/aio/_configuration.py | 8 +- .../aio/_monitor_management_client.py | 6 +- .../v2020_10_01/aio/operations/__init__.py | 2 +- .../_activity_log_alerts_operations.py | 127 +- .../monitor/v2020_10_01/models/__init__.py | 2 +- .../monitor/v2020_10_01/models/_models_py3.py | 93 +- .../v2020_10_01/operations/__init__.py | 2 +- .../_activity_log_alerts_operations.py | 155 ++- .../mgmt/monitor/v2021_04_01/__init__.py | 6 +- .../monitor/v2021_04_01/_configuration.py | 13 +- .../mgmt/monitor/v2021_04_01/_metadata.json | 30 +- .../v2021_04_01/_monitor_management_client.py | 13 +- .../azure/mgmt/monitor/v2021_04_01/_vendor.py | 5 +- .../mgmt/monitor/v2021_04_01/_version.py | 2 +- .../mgmt/monitor/v2021_04_01/aio/__init__.py | 6 +- .../monitor/v2021_04_01/aio/_configuration.py | 8 +- .../aio/_monitor_management_client.py | 6 +- .../v2021_04_01/aio/operations/__init__.py | 2 +- .../_data_collection_endpoints_operations.py | 127 +- ...collection_rule_associations_operations.py | 108 +- .../_data_collection_rules_operations.py | 127 +- .../monitor/v2021_04_01/models/__init__.py | 2 +- .../monitor/v2021_04_01/models/_models_py3.py | 297 ++--- .../v2021_04_01/operations/__init__.py | 2 +- .../_data_collection_endpoints_operations.py | 155 ++- ...collection_rule_associations_operations.py | 130 +- .../_data_collection_rules_operations.py | 155 ++- .../monitor/v2021_05_01_preview/__init__.py | 6 +- .../v2021_05_01_preview/_configuration.py | 13 +- .../v2021_05_01_preview/_metadata.json | 30 +- .../_monitor_management_client.py | 13 +- .../monitor/v2021_05_01_preview/_vendor.py | 5 +- .../monitor/v2021_05_01_preview/_version.py | 2 +- .../v2021_05_01_preview/aio/__init__.py | 6 +- .../v2021_05_01_preview/aio/_configuration.py | 8 +- .../aio/_monitor_management_client.py | 6 +- .../aio/operations/__init__.py | 2 +- .../_autoscale_settings_operations.py | 141 ++- ...diagnostic_settings_category_operations.py | 48 +- .../_diagnostic_settings_operations.py | 78 +- ...nt_group_diagnostic_settings_operations.py | 86 +- .../_predictive_metric_operations.py | 19 +- ...cription_diagnostic_settings_operations.py | 80 +- .../v2021_05_01_preview/models/__init__.py | 2 +- .../v2021_05_01_preview/models/_models_py3.py | 137 ++- .../operations/__init__.py | 2 +- .../_autoscale_settings_operations.py | 181 ++- ...diagnostic_settings_category_operations.py | 60 +- .../_diagnostic_settings_operations.py | 104 +- ...nt_group_diagnostic_settings_operations.py | 112 +- .../_predictive_metric_operations.py | 25 +- ...cription_diagnostic_settings_operations.py | 106 +- .../mgmt/monitor/v2021_09_01/__init__.py | 6 +- .../monitor/v2021_09_01/_configuration.py | 13 +- .../mgmt/monitor/v2021_09_01/_metadata.json | 30 +- .../v2021_09_01/_monitor_management_client.py | 13 +- .../azure/mgmt/monitor/v2021_09_01/_vendor.py | 5 +- .../mgmt/monitor/v2021_09_01/_version.py | 2 +- .../mgmt/monitor/v2021_09_01/aio/__init__.py | 6 +- .../monitor/v2021_09_01/aio/_configuration.py | 8 +- .../aio/_monitor_management_client.py | 6 +- .../v2021_09_01/aio/operations/__init__.py | 2 +- .../operations/_action_groups_operations.py | 295 +++-- .../monitor/v2021_09_01/models/__init__.py | 2 +- .../monitor/v2021_09_01/models/_models_py3.py | 82 +- .../v2021_09_01/operations/__init__.py | 2 +- .../operations/_action_groups_operations.py | 359 +++--- .../monitor/v2022_02_01_preview/__init__.py | 6 +- .../v2022_02_01_preview/_configuration.py | 13 +- .../v2022_02_01_preview/_metadata.json | 30 +- .../_monitor_management_client.py | 13 +- .../monitor/v2022_02_01_preview/_vendor.py | 5 +- .../monitor/v2022_02_01_preview/_version.py | 2 +- .../v2022_02_01_preview/aio/__init__.py | 6 +- .../v2022_02_01_preview/aio/_configuration.py | 8 +- .../aio/_monitor_management_client.py | 6 +- .../aio/operations/__init__.py | 2 +- .../_data_collection_endpoints_operations.py | 139 ++- ...collection_rule_associations_operations.py | 149 ++- .../_data_collection_rules_operations.py | 139 ++- .../v2022_02_01_preview/models/__init__.py | 2 +- .../v2022_02_01_preview/models/_models_py3.py | 346 +++--- .../operations/__init__.py | 2 +- .../_data_collection_endpoints_operations.py | 179 ++- ...collection_rule_associations_operations.py | 187 ++- .../_data_collection_rules_operations.py | 179 ++- .../mgmt/monitor/v2022_04_01/__init__.py | 6 +- .../monitor/v2022_04_01/_configuration.py | 13 +- .../mgmt/monitor/v2022_04_01/_metadata.json | 30 +- .../v2022_04_01/_monitor_management_client.py | 13 +- .../azure/mgmt/monitor/v2022_04_01/_vendor.py | 5 +- .../mgmt/monitor/v2022_04_01/_version.py | 2 +- .../mgmt/monitor/v2022_04_01/aio/__init__.py | 6 +- .../monitor/v2022_04_01/aio/_configuration.py | 8 +- .../aio/_monitor_management_client.py | 6 +- .../v2022_04_01/aio/operations/__init__.py | 2 +- .../operations/_action_groups_operations.py | 245 ++-- .../monitor/v2022_04_01/models/__init__.py | 2 +- .../monitor/v2022_04_01/models/_models_py3.py | 82 +- .../v2022_04_01/operations/__init__.py | 2 +- .../operations/_action_groups_operations.py | 299 +++-- .../mgmt/monitor/v2022_06_01/__init__.py | 6 +- .../monitor/v2022_06_01/_configuration.py | 13 +- .../mgmt/monitor/v2022_06_01/_metadata.json | 30 +- .../v2022_06_01/_monitor_management_client.py | 13 +- .../azure/mgmt/monitor/v2022_06_01/_vendor.py | 5 +- .../mgmt/monitor/v2022_06_01/_version.py | 2 +- .../mgmt/monitor/v2022_06_01/aio/__init__.py | 6 +- .../monitor/v2022_06_01/aio/_configuration.py | 8 +- .../aio/_monitor_management_client.py | 6 +- .../v2022_06_01/aio/operations/__init__.py | 2 +- .../operations/_action_groups_operations.py | 295 +++-- .../monitor/v2022_06_01/models/__init__.py | 2 +- .../monitor/v2022_06_01/models/_models_py3.py | 76 +- .../v2022_06_01/operations/__init__.py | 2 +- .../operations/_action_groups_operations.py | 359 +++--- .../monitor/v2022_08_01_preview/__init__.py | 26 + .../v2022_08_01_preview/_configuration.py | 72 ++ .../v2022_08_01_preview/_metadata.json | 110 ++ .../_monitor_management_client.py | 92 ++ .../monitor/v2022_08_01_preview/_patch.py | 20 + .../monitor/v2022_08_01_preview/_vendor.py | 30 + .../monitor/v2022_08_01_preview/_version.py | 9 + .../v2022_08_01_preview/aio/__init__.py | 23 + .../v2022_08_01_preview/aio/_configuration.py | 72 ++ .../aio/_monitor_management_client.py | 92 ++ .../monitor/v2022_08_01_preview/aio/_patch.py | 20 + .../aio/operations/__init__.py | 19 + .../aio/operations/_patch.py | 20 + .../_scheduled_query_rules_operations.py | 666 +++++++++++ .../v2022_08_01_preview/models/__init__.py | 63 + .../v2022_08_01_preview/models/_models_py3.py | 1059 +++++++++++++++++ .../_monitor_management_client_enums.py | 81 ++ .../v2022_08_01_preview/models/_patch.py | 20 + .../operations/__init__.py | 19 + .../v2022_08_01_preview/operations/_patch.py | 20 + .../_scheduled_query_rules_operations.py | 861 ++++++++++++++ .../mgmt/monitor/v2022_08_01_preview/py.typed | 1 + .../mgmt/monitor/v2022_10_01/__init__.py | 6 +- .../monitor/v2022_10_01/_configuration.py | 13 +- .../mgmt/monitor/v2022_10_01/_metadata.json | 30 +- .../v2022_10_01/_monitor_management_client.py | 13 +- .../azure/mgmt/monitor/v2022_10_01/_vendor.py | 5 +- .../mgmt/monitor/v2022_10_01/_version.py | 2 +- .../mgmt/monitor/v2022_10_01/aio/__init__.py | 6 +- .../monitor/v2022_10_01/aio/_configuration.py | 8 +- .../aio/_monitor_management_client.py | 6 +- .../v2022_10_01/aio/operations/__init__.py | 2 +- .../_autoscale_settings_operations.py | 129 +- .../_predictive_metric_operations.py | 17 +- .../monitor/v2022_10_01/models/__init__.py | 2 +- .../monitor/v2022_10_01/models/_models_py3.py | 87 +- .../v2022_10_01/operations/__init__.py | 2 +- .../_autoscale_settings_operations.py | 157 ++- .../_predictive_metric_operations.py | 21 +- 529 files changed, 15878 insertions(+), 7764 deletions(-) create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/generated_samples/create_or_update_autoscale_setting.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/generated_samples/delete_autoscale_setting.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/generated_samples/get_autoscale_setting.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/generated_samples/get_predictive_metric.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/generated_samples/list_autoscale_setting.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/generated_samples/list_autoscale_setting_by_subscription.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/generated_samples/patch_autoscale_setting.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/__init__.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/_configuration.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/_metadata.json create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/_monitor_management_client.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/_vendor.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/_version.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/aio/__init__.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/aio/_configuration.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/aio/_monitor_management_client.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/aio/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/aio/operations/__init__.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/aio/operations/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/aio/operations/_scheduled_query_rules_operations.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/models/__init__.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/models/_models_py3.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/models/_monitor_management_client_enums.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/models/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/operations/__init__.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/operations/_patch.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/operations/_scheduled_query_rules_operations.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/py.typed diff --git a/sdk/monitor/azure-mgmt-monitor/_meta.json b/sdk/monitor/azure-mgmt-monitor/_meta.json index 7fcbaaba2d28..6ed254b90b22 100644 --- a/sdk/monitor/azure-mgmt-monitor/_meta.json +++ b/sdk/monitor/azure-mgmt-monitor/_meta.json @@ -1,11 +1,11 @@ { + "commit": "26e345ad8ee56ce862b9c06ba95b721d05aa837b", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", "autorest": "3.9.2", "use": [ - "@autorest/python@6.1.9", + "@autorest/python@6.4.0", "@autorest/modelerfour@4.24.3" ], - "commit": "5263f0b2ead74031fa567da2700411743da26e7f", - "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/monitor/resource-manager/readme.md --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.1.9 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", + "autorest_command": "autorest specification/monitor/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.4.0 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", "readme": "specification/monitor/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/monitor/azure-mgmt-monitor/azure/generated_samples/create_or_update_autoscale_setting.py b/sdk/monitor/azure-mgmt-monitor/azure/generated_samples/create_or_update_autoscale_setting.py new file mode 100644 index 000000000000..c409d7ab02f1 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/generated_samples/create_or_update_autoscale_setting.py @@ -0,0 +1,160 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python create_or_update_autoscale_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 = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="b67f7fec-69fc-4974-9099-a26bd6ffeda3", + ) + + response = client.autoscale_settings.create_or_update( + resource_group_name="TestingMetricsScaleSet", + autoscale_setting_name="MySetting", + parameters={ + "location": "West US", + "properties": { + "enabled": True, + "notifications": [ + { + "email": { + "customEmails": ["gu@ms.com", "ge@ns.net"], + "sendToSubscriptionAdministrator": True, + "sendToSubscriptionCoAdministrators": True, + }, + "operation": "Scale", + "webhooks": [{"properties": {}, "serviceUri": "http://myservice.com"}], + } + ], + "predictiveAutoscalePolicy": {"scaleMode": "Enabled"}, + "profiles": [ + { + "capacity": {"default": "1", "maximum": "10", "minimum": "1"}, + "fixedDate": { + "end": "2015-03-05T14:30:00Z", + "start": "2015-03-05T14:00:00Z", + "timeZone": "UTC", + }, + "name": "adios", + "rules": [ + { + "metricTrigger": { + "dividePerInstance": False, + "metricName": "Percentage CPU", + "metricResourceUri": "/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/TestingMetricsScaleSet/providers/Microsoft.Compute/virtualMachineScaleSets/testingsc", + "operator": "GreaterThan", + "statistic": "Average", + "threshold": 10, + "timeAggregation": "Average", + "timeGrain": "PT1M", + "timeWindow": "PT5M", + }, + "scaleAction": { + "cooldown": "PT5M", + "direction": "Increase", + "type": "ChangeCount", + "value": "1", + }, + }, + { + "metricTrigger": { + "dividePerInstance": False, + "metricName": "Percentage CPU", + "metricResourceUri": "/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/TestingMetricsScaleSet/providers/Microsoft.Compute/virtualMachineScaleSets/testingsc", + "operator": "GreaterThan", + "statistic": "Average", + "threshold": 15, + "timeAggregation": "Average", + "timeGrain": "PT2M", + "timeWindow": "PT5M", + }, + "scaleAction": { + "cooldown": "PT6M", + "direction": "Decrease", + "type": "ChangeCount", + "value": "2", + }, + }, + ], + }, + { + "capacity": {"default": "1", "maximum": "10", "minimum": "1"}, + "name": "saludos", + "recurrence": { + "frequency": "Week", + "schedule": {"days": ["1"], "hours": [5], "minutes": [15], "timeZone": "UTC"}, + }, + "rules": [ + { + "metricTrigger": { + "dividePerInstance": False, + "metricName": "Percentage CPU", + "metricResourceUri": "/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/TestingMetricsScaleSet/providers/Microsoft.Compute/virtualMachineScaleSets/testingsc", + "operator": "GreaterThan", + "statistic": "Average", + "threshold": 10, + "timeAggregation": "Average", + "timeGrain": "PT1M", + "timeWindow": "PT5M", + }, + "scaleAction": { + "cooldown": "PT5M", + "direction": "Increase", + "type": "ChangeCount", + "value": "1", + }, + }, + { + "metricTrigger": { + "dividePerInstance": False, + "metricName": "Percentage CPU", + "metricResourceUri": "/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/TestingMetricsScaleSet/providers/Microsoft.Compute/virtualMachineScaleSets/testingsc", + "operator": "GreaterThan", + "statistic": "Average", + "threshold": 15, + "timeAggregation": "Average", + "timeGrain": "PT2M", + "timeWindow": "PT5M", + }, + "scaleAction": { + "cooldown": "PT6M", + "direction": "Decrease", + "type": "ChangeCount", + "value": "2", + }, + }, + ], + }, + ], + "targetResourceUri": "/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/TestingMetricsScaleSet/providers/Microsoft.Compute/virtualMachineScaleSets/testingsc", + }, + "tags": {"key1": "value1", "key2": "value2"}, + }, + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-10-01/examples/createOrUpdateAutoscaleSetting.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/generated_samples/delete_autoscale_setting.py b/sdk/monitor/azure-mgmt-monitor/azure/generated_samples/delete_autoscale_setting.py new file mode 100644 index 000000000000..38134eb2f5f7 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/generated_samples/delete_autoscale_setting.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.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python delete_autoscale_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 = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="b67f7fec-69fc-4974-9099-a26bd6ffeda3", + ) + + response = client.autoscale_settings.delete( + resource_group_name="TestingMetricsScaleSet", + autoscale_setting_name="MySetting", + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-10-01/examples/deleteAutoscaleSetting.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/generated_samples/get_autoscale_setting.py b/sdk/monitor/azure-mgmt-monitor/azure/generated_samples/get_autoscale_setting.py new file mode 100644 index 000000000000..a226c217890f --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/generated_samples/get_autoscale_setting.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.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python get_autoscale_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 = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="b67f7fec-69fc-4974-9099-a26bd6ffeda3", + ) + + response = client.autoscale_settings.get( + resource_group_name="TestingMetricsScaleSet", + autoscale_setting_name="MySetting", + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-10-01/examples/getAutoscaleSetting.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/generated_samples/get_predictive_metric.py b/sdk/monitor/azure-mgmt-monitor/azure/generated_samples/get_predictive_metric.py new file mode 100644 index 000000000000..7377ca8b3c93 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/generated_samples/get_predictive_metric.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 isodate + +from azure.identity import DefaultAzureCredential +from azure.mgmt.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python get_predictive_metric.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 = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.predictive_metric.get( + resource_group_name="myRG", + autoscale_setting_name="vmss1-Autoscale-775", + timespan="2021-10-14T22:00:00.000Z/2021-10-16T22:00:00.000Z", + interval=isodate.parse_duration("PT1H"), + metric_namespace="Microsoft.Compute/virtualMachineScaleSets", + metric_name="PercentageCPU", + aggregation="Total", + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-10-01/examples/GetPredictiveMetric.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/generated_samples/list_autoscale_setting.py b/sdk/monitor/azure-mgmt-monitor/azure/generated_samples/list_autoscale_setting.py new file mode 100644 index 000000000000..6d045787f78a --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/generated_samples/list_autoscale_setting.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.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python list_autoscale_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 = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="b67f7fec-69fc-4974-9099-a26bd6ffeda3", + ) + + response = client.autoscale_settings.list_by_resource_group( + resource_group_name="TestingMetricsScaleSet", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-10-01/examples/listAutoscaleSetting.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/generated_samples/list_autoscale_setting_by_subscription.py b/sdk/monitor/azure-mgmt-monitor/azure/generated_samples/list_autoscale_setting_by_subscription.py new file mode 100644 index 000000000000..ff5dfb5abdbf --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/generated_samples/list_autoscale_setting_by_subscription.py @@ -0,0 +1,39 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python list_autoscale_setting_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 = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="b67f7fec-69fc-4974-9099-a26bd6ffeda3", + ) + + response = client.autoscale_settings.list_by_subscription() + for item in response: + print(item) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-10-01/examples/listAutoscaleSettingBySubscription.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/generated_samples/patch_autoscale_setting.py b/sdk/monitor/azure-mgmt-monitor/azure/generated_samples/patch_autoscale_setting.py new file mode 100644 index 000000000000..e29c7c9957ef --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/generated_samples/patch_autoscale_setting.py @@ -0,0 +1,159 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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.monitor import MonitorManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-monitor +# USAGE + python patch_autoscale_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 = MonitorManagementClient( + credential=DefaultAzureCredential(), + subscription_id="b67f7fec-69fc-4974-9099-a26bd6ffeda3", + ) + + response = client.autoscale_settings.update( + resource_group_name="TestingMetricsScaleSet", + autoscale_setting_name="MySetting", + autoscale_setting_resource={ + "properties": { + "enabled": True, + "notifications": [ + { + "email": { + "customEmails": ["gu@ms.com", "ge@ns.net"], + "sendToSubscriptionAdministrator": True, + "sendToSubscriptionCoAdministrators": True, + }, + "operation": "Scale", + "webhooks": [{"properties": {}, "serviceUri": "http://myservice.com"}], + } + ], + "predictiveAutoscalePolicy": {"scaleMode": "Enabled"}, + "profiles": [ + { + "capacity": {"default": "1", "maximum": "10", "minimum": "1"}, + "fixedDate": { + "end": "2015-03-05T14:30:00Z", + "start": "2015-03-05T14:00:00Z", + "timeZone": "UTC", + }, + "name": "adios", + "rules": [ + { + "metricTrigger": { + "dividePerInstance": False, + "metricName": "Percentage CPU", + "metricResourceUri": "/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/TestingMetricsScaleSet/providers/Microsoft.Compute/virtualMachineScaleSets/testingsc", + "operator": "GreaterThan", + "statistic": "Average", + "threshold": 10, + "timeAggregation": "Average", + "timeGrain": "PT1M", + "timeWindow": "PT5M", + }, + "scaleAction": { + "cooldown": "PT5M", + "direction": "Increase", + "type": "ChangeCount", + "value": "1", + }, + }, + { + "metricTrigger": { + "dividePerInstance": False, + "metricName": "Percentage CPU", + "metricResourceUri": "/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/TestingMetricsScaleSet/providers/Microsoft.Compute/virtualMachineScaleSets/testingsc", + "operator": "GreaterThan", + "statistic": "Average", + "threshold": 15, + "timeAggregation": "Average", + "timeGrain": "PT2M", + "timeWindow": "PT5M", + }, + "scaleAction": { + "cooldown": "PT6M", + "direction": "Decrease", + "type": "ChangeCount", + "value": "2", + }, + }, + ], + }, + { + "capacity": {"default": "1", "maximum": "10", "minimum": "1"}, + "name": "saludos", + "recurrence": { + "frequency": "Week", + "schedule": {"days": ["1"], "hours": [5], "minutes": [15], "timeZone": "UTC"}, + }, + "rules": [ + { + "metricTrigger": { + "dividePerInstance": False, + "metricName": "Percentage CPU", + "metricResourceUri": "/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/TestingMetricsScaleSet/providers/Microsoft.Compute/virtualMachineScaleSets/testingsc", + "operator": "GreaterThan", + "statistic": "Average", + "threshold": 10, + "timeAggregation": "Average", + "timeGrain": "PT1M", + "timeWindow": "PT5M", + }, + "scaleAction": { + "cooldown": "PT5M", + "direction": "Increase", + "type": "ChangeCount", + "value": "1", + }, + }, + { + "metricTrigger": { + "dividePerInstance": False, + "metricName": "Percentage CPU", + "metricResourceUri": "/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/TestingMetricsScaleSet/providers/Microsoft.Compute/virtualMachineScaleSets/testingsc", + "operator": "GreaterThan", + "statistic": "Average", + "threshold": 15, + "timeAggregation": "Average", + "timeGrain": "PT2M", + "timeWindow": "PT5M", + }, + "scaleAction": { + "cooldown": "PT6M", + "direction": "Decrease", + "type": "ChangeCount", + "value": "2", + }, + }, + ], + }, + ], + "targetResourceUri": "/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/TestingMetricsScaleSet/providers/Microsoft.Compute/virtualMachineScaleSets/testingsc", + }, + "tags": {"key1": "value1"}, + }, + ) + print(response) + + +# x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-10-01/examples/patchAutoscaleSetting.json +if __name__ == "__main__": + main() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_configuration.py index 57808e3f861c..358c17303bd9 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_configuration.py @@ -36,9 +36,8 @@ def __init__( self, credential: "TokenCredential", subscription_id: str, - **kwargs # type: Any + **kwargs: Any ): - # type: (...) -> None if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -53,9 +52,8 @@ def __init__( def _configure( self, - **kwargs # type: Any + **kwargs: Any ): - # type: (...) -> None self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_monitor_management_client.py index e23ad2f2b416..3feeb4065609 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_monitor_management_client.py @@ -98,10 +98,10 @@ def __init__( self, credential: "TokenCredential", subscription_id: str, - api_version=None, # type: Optional[str] + api_version: Optional[str]=None, base_url: str = "https://management.azure.com", - profile=KnownProfiles.default, # type: KnownProfiles - **kwargs # type: Any + profile: KnownProfiles=KnownProfiles.default, + **kwargs: Any ): self._config = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) @@ -145,6 +145,7 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 2021-09-01-preview: :mod:`v2022_02_01_preview.models` * 2022-04-01: :mod:`v2022_04_01.models` * 2022-06-01: :mod:`v2022_06_01.models` + * 2022-08-01-preview: :mod:`v2022_08_01_preview.models` * 2022-10-01: :mod:`v2022_10_01.models` """ if api_version == '2015-04-01': @@ -228,6 +229,9 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2022-06-01': from .v2022_06_01 import models return models + elif api_version == '2022-08-01-preview': + from .v2022_08_01_preview import models + return models elif api_version == '2022-10-01': from .v2022_10_01 import models return models @@ -732,12 +736,15 @@ def scheduled_query_rules(self): * 2018-04-16: :class:`ScheduledQueryRulesOperations` * 2020-05-01-preview: :class:`ScheduledQueryRulesOperations` + * 2022-08-01-preview: :class:`ScheduledQueryRulesOperations` """ api_version = self._get_api_version('scheduled_query_rules') if api_version == '2018-04-16': from .v2018_04_16.operations import ScheduledQueryRulesOperations as OperationClass elif api_version == '2020-05-01-preview': from .v2020_05_01_preview.operations import ScheduledQueryRulesOperations as OperationClass + elif api_version == '2022-08-01-preview': + from .v2022_08_01_preview.operations import ScheduledQueryRulesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'scheduled_query_rules'".format(api_version)) self._config.api_version = api_version diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_serialization.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_serialization.py index 240df16c57f3..25467dfc00bb 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_serialization.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_serialization.py @@ -25,6 +25,7 @@ # -------------------------------------------------------------------------- # pylint: skip-file +# pyright: reportUnnecessaryTypeIgnoreComment=false from base64 import b64decode, b64encode import calendar @@ -37,34 +38,50 @@ import re import sys import codecs +from typing import ( + Dict, + Any, + cast, + Optional, + Union, + AnyStr, + IO, + Mapping, + Callable, + TypeVar, + MutableMapping, + Type, + List, + Mapping, +) + try: from urllib import quote # type: ignore except ImportError: - from urllib.parse import quote # type: ignore + from urllib.parse import quote import xml.etree.ElementTree as ET -import isodate - -from typing import Dict, Any, cast, TYPE_CHECKING +import isodate # type: ignore from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback +from azure.core.serialization import NULL as AzureCoreNull -_BOM = codecs.BOM_UTF8.decode(encoding='utf-8') +_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") + +ModelType = TypeVar("ModelType", bound="Model") +JSON = MutableMapping[str, Any] -if TYPE_CHECKING: - from typing import Optional, Union, AnyStr, IO, Mapping class RawDeserializer: # Accept "text" because we're open minded people... - JSON_REGEXP = re.compile(r'^(application|text)/([a-z+.]+\+)?json$') + JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") # Name used in context CONTEXT_NAME = "deserialized_data" @classmethod - def deserialize_from_text(cls, data, content_type=None): - # type: (Optional[Union[AnyStr, IO]], Optional[str]) -> Any + def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: Optional[str] = None) -> Any: """Decode data according to content-type. Accept a stream of data as well, but will be load at once in memory for now. @@ -75,12 +92,12 @@ def deserialize_from_text(cls, data, content_type=None): :type data: str or bytes or IO :param str content_type: The content type. """ - if hasattr(data, 'read'): + if hasattr(data, "read"): # Assume a stream data = cast(IO, data).read() if isinstance(data, bytes): - data_as_str = data.decode(encoding='utf-8-sig') + data_as_str = data.decode(encoding="utf-8-sig") else: # Explain to mypy the correct type. data_as_str = cast(str, data) @@ -116,7 +133,8 @@ def _json_attemp(data): try: return True, json.loads(data) except ValueError: - return False, None # Don't care about this one + return False, None # Don't care about this one + success, json_result = _json_attemp(data) if success: return json_result @@ -129,8 +147,7 @@ def _json_attemp(data): raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) @classmethod - def deserialize_from_http_generics(cls, body_bytes, headers): - # type: (Optional[Union[AnyStr, IO]], Mapping) -> Any + def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], headers: Mapping) -> Any: """Deserialize from HTTP response. Use bytes and headers to NOT use any requests/aiohttp or whatever @@ -139,8 +156,8 @@ def deserialize_from_http_generics(cls, body_bytes, headers): """ # Try to use content-type from headers if available content_type = None - if 'content-type' in headers: - content_type = headers['content-type'].split(";")[0].strip().lower() + if "content-type" in headers: + content_type = headers["content-type"].split(";")[0].strip().lower() # Ouch, this server did not declare what it sent... # Let's guess it's JSON... # Also, since Autorest was considering that an empty body was a valid JSON, @@ -152,20 +169,22 @@ def deserialize_from_http_generics(cls, body_bytes, headers): return cls.deserialize_from_text(body_bytes, content_type) return None + try: basestring # type: ignore unicode_str = unicode # type: ignore except NameError: - basestring = str # type: ignore - unicode_str = str # type: ignore + basestring = str + unicode_str = str _LOGGER = logging.getLogger(__name__) try: - _long_type = long # type: ignore + _long_type = long # type: ignore except NameError: _long_type = int + class UTC(datetime.tzinfo): """Time Zone info for handling UTC""" @@ -181,9 +200,11 @@ def dst(self, dt): """No daylight saving for UTC.""" return datetime.timedelta(hours=1) + try: - from datetime import timezone as _FixedOffset + from datetime import timezone as _FixedOffset # type: ignore except ImportError: # Python 2.7 + class _FixedOffset(datetime.tzinfo): # type: ignore """Fixed offset in minutes east from UTC. Copy/pasted from Python doc @@ -197,7 +218,7 @@ def utcoffset(self, dt): return self.__offset def tzname(self, dt): - return str(self.__offset.total_seconds()/3600) + return str(self.__offset.total_seconds() / 3600) def __repr__(self): return "".format(self.tzname(None)) @@ -208,14 +229,17 @@ def dst(self, dt): def __getinitargs__(self): return (self.__offset,) + try: from datetime import timezone - TZ_UTC = timezone.utc # type: ignore + + TZ_UTC = timezone.utc except ImportError: TZ_UTC = UTC() # type: ignore _FLATTEN = re.compile(r"(? None: + self.additional_properties: 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__) @@ -276,47 +304,42 @@ def __init__(self, **kwargs): else: setattr(self, k, kwargs[k]) - def __eq__(self, other): + def __eq__(self, other: Any) -> bool: """Compare objects by comparing all attributes.""" if isinstance(other, self.__class__): return self.__dict__ == other.__dict__ return False - def __ne__(self, other): + def __ne__(self, other: Any) -> bool: """Compare objects by comparing all attributes.""" return not self.__eq__(other) - def __str__(self): + def __str__(self) -> str: return str(self.__dict__) @classmethod - def enable_additional_properties_sending(cls): - cls._attribute_map['additional_properties'] = {'key': '', 'type': '{object}'} + def enable_additional_properties_sending(cls) -> None: + cls._attribute_map["additional_properties"] = {"key": "", "type": "{object}"} @classmethod - def is_xml_model(cls): + def is_xml_model(cls) -> bool: try: - cls._xml_map + cls._xml_map # type: ignore except AttributeError: return False return True @classmethod def _create_xml_node(cls): - """Create XML node. - """ + """Create XML node.""" try: - xml_map = cls._xml_map + xml_map = cls._xml_map # type: ignore except AttributeError: xml_map = {} - return _create_xml_node( - xml_map.get('name', cls.__name__), - xml_map.get("prefix", None), - xml_map.get("ns", None) - ) + 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=False, **kwargs): + def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: """Return the JSON that would be sent to azure from this model. This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. @@ -330,8 +353,15 @@ def serialize(self, keep_readonly=False, **kwargs): serializer = Serializer(self._infer_class_models()) return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) - def as_dict(self, keep_readonly=True, key_transformer=attribute_transformer, **kwargs): - """Return a dict that can be JSONify using json.dump. + def as_dict( + self, + keep_readonly: bool = True, + key_transformer: Callable[ + [str, Dict[str, Any], Any], Any + ] = attribute_transformer, + **kwargs: Any + ) -> JSON: + """Return a dict that can be serialized using json.dump. Advanced usage might optionally use a callback as parameter: @@ -367,7 +397,7 @@ def my_key_transformer(key, attr_desc, value): @classmethod def _infer_class_models(cls): try: - str_models = cls.__module__.rsplit('.', 1)[0] + str_models = cls.__module__.rsplit(".", 1)[0] models = sys.modules[str_models] client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} if cls.__name__ not in client_models: @@ -378,7 +408,7 @@ def _infer_class_models(cls): return client_models @classmethod - def deserialize(cls, data, content_type=None): + def deserialize(cls: Type[ModelType], data: Any, content_type: Optional[str] = None) -> ModelType: """Parse a str using the RestAPI syntax and return a model. :param str data: A str using RestAPI structure. JSON by default. @@ -390,7 +420,12 @@ def deserialize(cls, data, content_type=None): return deserializer(cls.__name__, data, content_type=content_type) @classmethod - def from_dict(cls, data, key_extractors=None, content_type=None): + def from_dict( + cls: Type[ModelType], + data: Any, + key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, + content_type: Optional[str] = None, + ) -> ModelType: """Parse a dict using given key extractor return a model. By default consider key @@ -403,16 +438,20 @@ def from_dict(cls, data, key_extractors=None, content_type=None): :raises: DeserializationError if something went wrong """ deserializer = Deserializer(cls._infer_class_models()) - deserializer.key_extractors = [ - attribute_key_case_insensitive_extractor, - rest_key_case_insensitive_extractor, - last_rest_key_case_insensitive_extractor - ] if key_extractors is None else key_extractors + deserializer.key_extractors = ( # type: ignore + [ # type: ignore + attribute_key_case_insensitive_extractor, + rest_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor, + ] + if key_extractors is None + else key_extractors + ) return deserializer(cls.__name__, data, content_type=content_type) @classmethod def _flatten_subtype(cls, key, objects): - if '_subtype_map' not in cls.__dict__: + if "_subtype_map" not in cls.__dict__: return {} result = dict(cls._subtype_map[key]) for valuetype in cls._subtype_map[key].values(): @@ -425,18 +464,14 @@ def _classify(cls, response, objects): We want to ignore any inherited _subtype_maps. Remove the polymorphic key from the initial data. """ - for subtype_key in cls.__dict__.get('_subtype_map', {}).keys(): + for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): subtype_value = None if not isinstance(response, ET.Element): rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] subtype_value = response.pop(rest_api_response_key, None) or response.pop(subtype_key, None) else: - subtype_value = xml_key_extractor( - subtype_key, - cls._attribute_map[subtype_key], - response - ) + subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) if subtype_value: # Try to match base class. Can be class name only # (bug to fix in Autorest to support x-ms-discriminator-name) @@ -444,7 +479,7 @@ def _classify(cls, response, objects): return cls flatten_mapping_type = cls._flatten_subtype(subtype_key, objects) try: - return objects[flatten_mapping_type[subtype_value]] + return objects[flatten_mapping_type[subtype_value]] # type: ignore except KeyError: _LOGGER.warning( "Subtype value %s has no mapping, use base class %s.", @@ -453,11 +488,7 @@ def _classify(cls, response, objects): ) break else: - _LOGGER.warning( - "Discriminator %s is absent or null, use base class %s.", - subtype_key, - cls.__name__ - ) + _LOGGER.warning("Discriminator %s is absent or null, use base class %s.", subtype_key, cls.__name__) break return cls @@ -468,29 +499,40 @@ def _get_rest_key_parts(cls, attr_key): :returns: A list of RestAPI part :rtype: list """ - rest_split_key = _FLATTEN.split(cls._attribute_map[attr_key]['key']) + rest_split_key = _FLATTEN.split(cls._attribute_map[attr_key]["key"]) return [_decode_attribute_map_key(key_part) for key_part in rest_split_key] def _decode_attribute_map_key(key): """This decode a key in an _attribute_map to the actual key we want to look at - inside the received data. + inside the received data. - :param str key: A key string from the generated code + :param str key: A key string from the generated code """ - return key.replace('\\.', '.') + return key.replace("\\.", ".") class Serializer(object): """Request object model serializer.""" - basic_types = {str: 'str', int: 'int', bool: 'bool', float: 'float'} - - _xml_basic_types_serializers = {'bool': lambda x:str(x).lower()} - days = {0: "Mon", 1: "Tue", 2: "Wed", 3: "Thu", - 4: "Fri", 5: "Sat", 6: "Sun"} - months = {1: "Jan", 2: "Feb", 3: "Mar", 4: "Apr", 5: "May", 6: "Jun", - 7: "Jul", 8: "Aug", 9: "Sep", 10: "Oct", 11: "Nov", 12: "Dec"} + basic_types = {str: "str", int: "int", bool: "bool", float: "float"} + + _xml_basic_types_serializers = {"bool": lambda x: str(x).lower()} + days = {0: "Mon", 1: "Tue", 2: "Wed", 3: "Thu", 4: "Fri", 5: "Sat", 6: "Sun"} + months = { + 1: "Jan", + 2: "Feb", + 3: "Mar", + 4: "Apr", + 5: "May", + 6: "Jun", + 7: "Jul", + 8: "Aug", + 9: "Sep", + 10: "Oct", + 11: "Nov", + 12: "Dec", + } validation = { "min_length": lambda x, y: len(x) < y, "max_length": lambda x, y: len(x) > y, @@ -502,26 +544,26 @@ class Serializer(object): "max_items": lambda x, y: len(x) > y, "pattern": lambda x, y: not re.match(y, x, re.UNICODE), "unique": lambda x, y: len(x) != len(set(x)), - "multiple": lambda x, y: x % y != 0 - } + "multiple": lambda x, y: x % y != 0, + } - def __init__(self, classes=None): + def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]]=None): self.serialize_type = { - 'iso-8601': Serializer.serialize_iso, - 'rfc-1123': Serializer.serialize_rfc, - 'unix-time': Serializer.serialize_unix, - 'duration': Serializer.serialize_duration, - 'date': Serializer.serialize_date, - 'time': Serializer.serialize_time, - 'decimal': Serializer.serialize_decimal, - 'long': Serializer.serialize_long, - 'bytearray': Serializer.serialize_bytearray, - 'base64': Serializer.serialize_base64, - 'object': self.serialize_object, - '[]': self.serialize_iter, - '{}': self.serialize_dict - } - self.dependencies = dict(classes) if classes else {} + "iso-8601": Serializer.serialize_iso, + "rfc-1123": Serializer.serialize_rfc, + "unix-time": Serializer.serialize_unix, + "duration": Serializer.serialize_duration, + "date": Serializer.serialize_date, + "time": Serializer.serialize_time, + "decimal": Serializer.serialize_decimal, + "long": Serializer.serialize_long, + "bytearray": Serializer.serialize_bytearray, + "base64": Serializer.serialize_base64, + "object": self.serialize_object, + "[]": self.serialize_iter, + "{}": self.serialize_dict, + } + self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} self.key_transformer = full_restapi_key_transformer self.client_side_validation = True @@ -542,14 +584,12 @@ def _serialize(self, target_obj, data_type=None, **kwargs): class_name = target_obj.__class__.__name__ if data_type: - return self.serialize_data( - target_obj, data_type, **kwargs) + return self.serialize_data(target_obj, data_type, **kwargs) if not hasattr(target_obj, "_attribute_map"): data_type = type(target_obj).__name__ if data_type in self.basic_types.values(): - return self.serialize_data( - target_obj, data_type, **kwargs) + return self.serialize_data(target_obj, data_type, **kwargs) # Force "is_xml" kwargs if we detect a XML model try: @@ -564,10 +604,10 @@ def _serialize(self, target_obj, data_type=None, **kwargs): attributes = target_obj._attribute_map for attr, attr_desc in attributes.items(): attr_name = attr - if not keep_readonly and target_obj._validation.get(attr_name, {}).get('readonly', False): + if not keep_readonly and target_obj._validation.get(attr_name, {}).get("readonly", False): continue - if attr_name == "additional_properties" and attr_desc["key"] == '': + if attr_name == "additional_properties" and attr_desc["key"] == "": if target_obj.additional_properties is not None: serialized.update(target_obj.additional_properties) continue @@ -575,68 +615,60 @@ def _serialize(self, target_obj, data_type=None, **kwargs): orig_attr = getattr(target_obj, attr) if is_xml_model_serialization: - pass # Don't provide "transformer" for XML for now. Keep "orig_attr" - else: # JSON + pass # Don't provide "transformer" for XML for now. Keep "orig_attr" + else: # JSON keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) keys = keys if isinstance(keys, list) else [keys] - kwargs["serialization_ctxt"] = attr_desc - new_attr = self.serialize_data(orig_attr, attr_desc['type'], **kwargs) - + new_attr = self.serialize_data(orig_attr, attr_desc["type"], **kwargs) if is_xml_model_serialization: - xml_desc = attr_desc.get('xml', {}) - xml_name = xml_desc.get('name', attr_desc['key']) - xml_prefix = xml_desc.get('prefix', None) - xml_ns = xml_desc.get('ns', None) + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + xml_prefix = xml_desc.get("prefix", None) + xml_ns = xml_desc.get("ns", None) if xml_desc.get("attr", False): if xml_ns: ET.register_namespace(xml_prefix, xml_ns) xml_name = "{}{}".format(xml_ns, xml_name) - serialized.set(xml_name, new_attr) + serialized.set(xml_name, new_attr) # type: ignore continue if xml_desc.get("text", False): - serialized.text = new_attr + serialized.text = new_attr # type: ignore continue if isinstance(new_attr, list): - serialized.extend(new_attr) + serialized.extend(new_attr) # type: ignore elif isinstance(new_attr, ET.Element): # If the down XML has no XML/Name, we MUST replace the tag with the local tag. But keeping the namespaces. - if 'name' not in getattr(orig_attr, '_xml_map', {}): + if "name" not in getattr(orig_attr, "_xml_map", {}): splitted_tag = new_attr.tag.split("}") - if len(splitted_tag) == 2: # Namespace + if len(splitted_tag) == 2: # Namespace new_attr.tag = "}".join([splitted_tag[0], xml_name]) else: new_attr.tag = xml_name - serialized.append(new_attr) + serialized.append(new_attr) # type: ignore else: # That's a basic type # Integrate namespace if necessary - local_node = _create_xml_node( - xml_name, - xml_prefix, - xml_ns - ) + local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) local_node.text = unicode_str(new_attr) - serialized.append(local_node) - else: # JSON - for k in reversed(keys): - unflattened = {k: new_attr} - new_attr = unflattened + serialized.append(local_node) # type: ignore + else: # JSON + for k in reversed(keys): # type: ignore + new_attr = {k: new_attr} _new_attr = new_attr _serialized = serialized - for k in keys: + for k in keys: # type: ignore if k not in _serialized: - _serialized.update(_new_attr) - _new_attr = _new_attr[k] + _serialized.update(_new_attr) # type: ignore + _new_attr = _new_attr[k] # type: ignore _serialized = _serialized[k] except ValueError: continue except (AttributeError, KeyError, TypeError) as err: - msg = "Attribute {} in object {} cannot be serialized.\n{}".format( - attr_name, class_name, str(target_obj)) + msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) raise_with_traceback(SerializationError, msg, err) else: return serialized @@ -652,8 +684,8 @@ def body(self, data, data_type, **kwargs): """ # Just in case this is a dict - internal_data_type = data_type.strip('[]{}') - internal_data_type = self.dependencies.get(internal_data_type, None) + internal_data_type_str = data_type.strip("[]{}") + internal_data_type = self.dependencies.get(internal_data_type_str, None) try: is_xml_model_serialization = kwargs["is_xml"] except KeyError: @@ -668,19 +700,18 @@ def body(self, data, data_type, **kwargs): # We're not able to deal with additional properties for now. deserializer.additional_properties_detection = False if is_xml_model_serialization: - deserializer.key_extractors = [ + deserializer.key_extractors = [ # type: ignore attribute_key_case_insensitive_extractor, ] else: deserializer.key_extractors = [ rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor, - last_rest_key_case_insensitive_extractor + last_rest_key_case_insensitive_extractor, ] data = deserializer._deserialize(data_type, data) except DeserializationError as err: - raise_with_traceback( - SerializationError, "Unable to build a model: "+str(err), err) + raise_with_traceback(SerializationError, "Unable to build a model: " + str(err), err) return self._serialize(data, data_type, **kwargs) @@ -695,13 +726,13 @@ def url(self, name, data, data_type, **kwargs): """ try: output = self.serialize_data(data, data_type, **kwargs) - if data_type == 'bool': + if data_type == "bool": output = json.dumps(output) - if kwargs.get('skip_quote') is True: + if kwargs.get("skip_quote") is True: output = str(output) else: - output = quote(str(output), safe='') + output = quote(str(output), safe="") except SerializationError: raise TypeError("{} must be type {}.".format(name, data_type)) else: @@ -720,27 +751,19 @@ def query(self, name, data, data_type, **kwargs): # Treat the list aside, since we don't want to encode the div separator if data_type.startswith("["): internal_data_type = data_type[1:-1] - data = [ - self.serialize_data(d, internal_data_type, **kwargs) if d is not None else "" - for d - in data - ] - if not kwargs.get('skip_quote', False): - data = [ - quote(str(d), safe='') - for d - in data - ] + data = [self.serialize_data(d, internal_data_type, **kwargs) if d is not None else "" for d in data] + if not kwargs.get("skip_quote", False): + data = [quote(str(d), safe="") for d in data] return str(self.serialize_iter(data, internal_data_type, **kwargs)) # Not a list, regular serialization output = self.serialize_data(data, data_type, **kwargs) - if data_type == 'bool': + if data_type == "bool": output = json.dumps(output) - if kwargs.get('skip_quote') is True: + if kwargs.get("skip_quote") is True: output = str(output) else: - output = quote(str(output), safe='') + output = quote(str(output), safe="") except SerializationError: raise TypeError("{} must be type {}.".format(name, data_type)) else: @@ -756,11 +779,11 @@ def header(self, name, data, data_type, **kwargs): :raises: ValueError if data is None """ try: - if data_type in ['[str]']: + if data_type in ["[str]"]: data = ["" if d is None else d for d in data] output = self.serialize_data(data, data_type, **kwargs) - if data_type == 'bool': + if data_type == "bool": output = json.dumps(output) except SerializationError: raise TypeError("{} must be type {}.".format(name, data_type)) @@ -782,6 +805,8 @@ def serialize_data(self, data, data_type, **kwargs): raise ValueError("No value for given attribute") try: + if data is AzureCoreNull: + return None if data_type in self.basic_types.values(): return self.serialize_basic(data, data_type, **kwargs) @@ -796,13 +821,11 @@ def serialize_data(self, data, data_type, **kwargs): iter_type = data_type[0] + data_type[-1] if iter_type in self.serialize_type: - return self.serialize_type[iter_type]( - data, data_type[1:-1], **kwargs) + return self.serialize_type[iter_type](data, data_type[1:-1], **kwargs) except (ValueError, TypeError) as err: msg = "Unable to serialize value: {!r} as type: {!r}." - raise_with_traceback( - SerializationError, msg.format(data, data_type), err) + raise_with_traceback(SerializationError, msg.format(data, data_type), err) else: return self._serialize(data, **kwargs) @@ -829,7 +852,7 @@ def serialize_basic(cls, data, data_type, **kwargs): custom_serializer = cls._get_custom_serializers(data_type, **kwargs) if custom_serializer: return custom_serializer(data) - if data_type == 'str': + if data_type == "str": return cls.serialize_unicode(data) return eval(data_type)(data) # nosec @@ -847,7 +870,7 @@ def serialize_unicode(cls, data): pass try: - if isinstance(data, unicode): + if isinstance(data, unicode): # type: ignore # Don't change it, JSON and XML ElementTree are totally able # to serialize correctly u'' strings return data @@ -886,25 +909,21 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): serialized.append(None) if div: - serialized = ['' if s is None else str(s) for s in serialized] + serialized = ["" if s is None else str(s) for s in serialized] serialized = div.join(serialized) - if 'xml' in serialization_ctxt or is_xml: + if "xml" in serialization_ctxt or is_xml: # XML serialization is more complicated - xml_desc = serialization_ctxt.get('xml', {}) - xml_name = xml_desc.get('name') + xml_desc = serialization_ctxt.get("xml", {}) + xml_name = xml_desc.get("name") if not xml_name: - xml_name = serialization_ctxt['key'] + xml_name = serialization_ctxt["key"] # Create a wrap node if necessary (use the fact that Element and list have "append") is_wrapped = xml_desc.get("wrapped", False) node_name = xml_desc.get("itemsName", xml_name) if is_wrapped: - final_result = _create_xml_node( - xml_name, - xml_desc.get('prefix', None), - xml_desc.get('ns', None) - ) + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) else: final_result = [] # All list elements to "local_node" @@ -912,11 +931,7 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): if isinstance(el, ET.Element): el_node = el else: - el_node = _create_xml_node( - node_name, - xml_desc.get('prefix', None), - xml_desc.get('ns', None) - ) + el_node = _create_xml_node(node_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) if el is not None: # Otherwise it writes "None" :-p el_node.text = str(el) final_result.append(el_node) @@ -936,21 +951,16 @@ def serialize_dict(self, attr, dict_type, **kwargs): serialized = {} for key, value in attr.items(): try: - serialized[self.serialize_unicode(key)] = self.serialize_data( - value, dict_type, **kwargs) + serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) except ValueError: serialized[self.serialize_unicode(key)] = None - if 'xml' in serialization_ctxt: + if "xml" in serialization_ctxt: # XML serialization is more complicated - xml_desc = serialization_ctxt['xml'] - xml_name = xml_desc['name'] + xml_desc = serialization_ctxt["xml"] + xml_name = xml_desc["name"] - final_result = _create_xml_node( - xml_name, - xml_desc.get('prefix', None), - xml_desc.get('ns', None) - ) + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) for key, value in serialized.items(): ET.SubElement(final_result, key).text = value return final_result @@ -996,8 +1006,7 @@ def serialize_object(self, attr, **kwargs): serialized = {} for key, value in attr.items(): try: - serialized[self.serialize_unicode(key)] = self.serialize_object( - value, **kwargs) + serialized[self.serialize_unicode(key)] = self.serialize_object(value, **kwargs) except ValueError: serialized[self.serialize_unicode(key)] = None return serialized @@ -1006,8 +1015,7 @@ def serialize_object(self, attr, **kwargs): serialized = [] for obj in attr: try: - serialized.append(self.serialize_object( - obj, **kwargs)) + serialized.append(self.serialize_object(obj, **kwargs)) except ValueError: pass return serialized @@ -1020,10 +1028,10 @@ def serialize_enum(attr, enum_obj=None): except AttributeError: result = attr try: - enum_obj(result) + enum_obj(result) # type: ignore return result except ValueError: - for enum_value in enum_obj: + for enum_value in enum_obj: # type: ignore if enum_value.value.lower() == str(attr).lower(): return enum_value.value error = "{!r} is not valid value for enum {!r}" @@ -1045,8 +1053,8 @@ def serialize_base64(attr, **kwargs): :param attr: Object to be serialized. :rtype: str """ - encoded = b64encode(attr).decode('ascii') - return encoded.strip('=').replace('+', '-').replace('/', '_') + encoded = b64encode(attr).decode("ascii") + return encoded.strip("=").replace("+", "-").replace("/", "_") @staticmethod def serialize_decimal(attr, **kwargs): @@ -1113,16 +1121,20 @@ def serialize_rfc(attr, **kwargs): """ try: if not attr.tzinfo: - _LOGGER.warning( - "Datetime with no tzinfo will be considered UTC.") + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") utc = attr.utctimetuple() except AttributeError: raise TypeError("RFC1123 object must be valid Datetime object.") return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( - Serializer.days[utc.tm_wday], utc.tm_mday, - Serializer.months[utc.tm_mon], utc.tm_year, - utc.tm_hour, utc.tm_min, utc.tm_sec) + Serializer.days[utc.tm_wday], + utc.tm_mday, + Serializer.months[utc.tm_mon], + utc.tm_year, + utc.tm_hour, + utc.tm_min, + utc.tm_sec, + ) @staticmethod def serialize_iso(attr, **kwargs): @@ -1136,19 +1148,18 @@ def serialize_iso(attr, **kwargs): attr = isodate.parse_datetime(attr) try: if not attr.tzinfo: - _LOGGER.warning( - "Datetime with no tzinfo will be considered UTC.") + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") utc = attr.utctimetuple() if utc.tm_year > 9999 or utc.tm_year < 1: raise OverflowError("Hit max or min date") - microseconds = str(attr.microsecond).rjust(6,'0').rstrip('0').ljust(3, '0') + microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") if microseconds: - microseconds = '.'+microseconds + microseconds = "." + microseconds date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( - utc.tm_year, utc.tm_mon, utc.tm_mday, - utc.tm_hour, utc.tm_min, utc.tm_sec) - return date + microseconds + 'Z' + utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec + ) + return date + microseconds + "Z" except (ValueError, OverflowError) as err: msg = "Unable to serialize datetime object." raise_with_traceback(SerializationError, msg, err) @@ -1169,18 +1180,19 @@ def serialize_unix(attr, **kwargs): return attr try: if not attr.tzinfo: - _LOGGER.warning( - "Datetime with no tzinfo will be considered UTC.") + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") return int(calendar.timegm(attr.utctimetuple())) except AttributeError: raise TypeError("Unix time object must be valid Datetime object.") + def rest_key_extractor(attr, attr_desc, data): - key = attr_desc['key'] + key = attr_desc["key"] working_data = data - while '.' in key: - dict_keys = _FLATTEN.split(key) + while "." in key: + # Need the cast, as for some reasons "split" is typed as list[str | Any] + dict_keys = cast(List[str], _FLATTEN.split(key)) if len(dict_keys) == 1: key = _decode_attribute_map_key(dict_keys[0]) break @@ -1191,15 +1203,16 @@ def rest_key_extractor(attr, attr_desc, data): # that all properties under are None as well # https://github.com/Azure/msrest-for-python/issues/197 return None - key = '.'.join(dict_keys[1:]) + key = ".".join(dict_keys[1:]) return working_data.get(key) + def rest_key_case_insensitive_extractor(attr, attr_desc, data): - key = attr_desc['key'] + key = attr_desc["key"] working_data = data - while '.' in key: + while "." in key: dict_keys = _FLATTEN.split(key) if len(dict_keys) == 1: key = _decode_attribute_map_key(dict_keys[0]) @@ -1211,30 +1224,33 @@ def rest_key_case_insensitive_extractor(attr, attr_desc, data): # that all properties under are None as well # https://github.com/Azure/msrest-for-python/issues/197 return None - key = '.'.join(dict_keys[1:]) + key = ".".join(dict_keys[1:]) if working_data: return attribute_key_case_insensitive_extractor(key, None, working_data) + def last_rest_key_extractor(attr, attr_desc, data): - """Extract the attribute in "data" based on the last part of the JSON path key. - """ - key = attr_desc['key'] + """Extract the attribute in "data" based on the last part of the JSON path key.""" + key = attr_desc["key"] dict_keys = _FLATTEN.split(key) return attribute_key_extractor(dict_keys[-1], None, data) + def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): """Extract the attribute in "data" based on the last part of the JSON path key. This is the case insensitive version of "last_rest_key_extractor" """ - key = attr_desc['key'] + key = attr_desc["key"] dict_keys = _FLATTEN.split(key) return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) + def attribute_key_extractor(attr, _, data): return data.get(attr) + def attribute_key_case_insensitive_extractor(attr, _, data): found_key = None lower_attr = attr.lower() @@ -1245,6 +1261,7 @@ def attribute_key_case_insensitive_extractor(attr, _, data): return data.get(found_key) + def _extract_name_from_internal_type(internal_type): """Given an internal type XML description, extract correct XML name with namespace. @@ -1253,7 +1270,7 @@ def _extract_name_from_internal_type(internal_type): :returns: A tuple XML name + namespace dict """ internal_type_xml_map = getattr(internal_type, "_xml_map", {}) - xml_name = internal_type_xml_map.get('name', internal_type.__name__) + xml_name = internal_type_xml_map.get("name", internal_type.__name__) xml_ns = internal_type_xml_map.get("ns", None) if xml_ns: xml_name = "{}{}".format(xml_ns, xml_name) @@ -1268,17 +1285,17 @@ def xml_key_extractor(attr, attr_desc, data): if not isinstance(data, ET.Element): return None - xml_desc = attr_desc.get('xml', {}) - xml_name = xml_desc.get('name', attr_desc['key']) + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) # Look for a children - is_iter_type = attr_desc['type'].startswith("[") + is_iter_type = attr_desc["type"].startswith("[") is_wrapped = xml_desc.get("wrapped", False) internal_type = attr_desc.get("internalType", None) internal_type_xml_map = getattr(internal_type, "_xml_map", {}) # Integrate namespace if necessary - xml_ns = xml_desc.get('ns', internal_type_xml_map.get("ns", None)) + xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) if xml_ns: xml_name = "{}{}".format(xml_ns, xml_name) @@ -1294,15 +1311,15 @@ def xml_key_extractor(attr, attr_desc, data): # - Wrapped node # - Internal type is an enum (considered basic types) # - Internal type has no XML/Name node - if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or 'name' not in internal_type_xml_map)): + if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or "name" not in internal_type_xml_map)): children = data.findall(xml_name) # If internal type has a local name and it's not a list, I use that name - elif not is_iter_type and internal_type and 'name' in internal_type_xml_map: + elif not is_iter_type and internal_type and "name" in internal_type_xml_map: xml_name = _extract_name_from_internal_type(internal_type) children = data.findall(xml_name) # That's an array else: - if internal_type: # Complex type, ignore itemsName and use the complex type name + if internal_type: # Complex type, ignore itemsName and use the complex type name items_name = _extract_name_from_internal_type(internal_type) else: items_name = xml_desc.get("itemsName", xml_name) @@ -1311,21 +1328,22 @@ def xml_key_extractor(attr, attr_desc, data): if len(children) == 0: if is_iter_type: if is_wrapped: - return None # is_wrapped no node, we want None + return None # is_wrapped no node, we want None else: - return [] # not wrapped, assume empty list + return [] # not wrapped, assume empty list return None # Assume it's not there, maybe an optional node. # If is_iter_type and not wrapped, return all found children if is_iter_type: if not is_wrapped: return children - else: # Iter and wrapped, should have found one node only (the wrap one) + else: # Iter and wrapped, should have found one node only (the wrap one) if len(children) != 1: raise DeserializationError( "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( xml_name - )) + ) + ) return list(children[0]) # Might be empty list and that's ok. # Here it's not a itertype, we should have found one element only or empty @@ -1333,6 +1351,7 @@ def xml_key_extractor(attr, attr_desc, data): raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) return children[0] + class Deserializer(object): """Response object model deserializer. @@ -1340,37 +1359,32 @@ class Deserializer(object): :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. """ - basic_types = {str: 'str', int: 'int', bool: 'bool', float: 'float'} + basic_types = {str: "str", int: "int", bool: "bool", float: "float"} - valid_date = re.compile( - r'\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}' - r'\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?') + valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - def __init__(self, classes=None): + def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]]=None): self.deserialize_type = { - 'iso-8601': Deserializer.deserialize_iso, - 'rfc-1123': Deserializer.deserialize_rfc, - 'unix-time': Deserializer.deserialize_unix, - 'duration': Deserializer.deserialize_duration, - 'date': Deserializer.deserialize_date, - 'time': Deserializer.deserialize_time, - 'decimal': Deserializer.deserialize_decimal, - 'long': Deserializer.deserialize_long, - 'bytearray': Deserializer.deserialize_bytearray, - 'base64': Deserializer.deserialize_base64, - 'object': self.deserialize_object, - '[]': self.deserialize_iter, - '{}': self.deserialize_dict - } + "iso-8601": Deserializer.deserialize_iso, + "rfc-1123": Deserializer.deserialize_rfc, + "unix-time": Deserializer.deserialize_unix, + "duration": Deserializer.deserialize_duration, + "date": Deserializer.deserialize_date, + "time": Deserializer.deserialize_time, + "decimal": Deserializer.deserialize_decimal, + "long": Deserializer.deserialize_long, + "bytearray": Deserializer.deserialize_bytearray, + "base64": Deserializer.deserialize_base64, + "object": self.deserialize_object, + "[]": self.deserialize_iter, + "{}": self.deserialize_dict, + } self.deserialize_expected_types = { - 'duration': (isodate.Duration, datetime.timedelta), - 'iso-8601': (datetime.datetime) + "duration": (isodate.Duration, datetime.timedelta), + "iso-8601": (datetime.datetime), } - self.dependencies = dict(classes) if classes else {} - self.key_extractors = [ - rest_key_extractor, - xml_key_extractor - ] + self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} + self.key_extractors = [rest_key_extractor, xml_key_extractor] # Additional properties only works if the "rest_key_extractor" is used to # extract the keys. Making it to work whatever the key extractor is too much # complicated, with no real scenario for now. @@ -1403,8 +1417,7 @@ def _deserialize(self, target_obj, data): """ # This is already a model, go recursive just in case if hasattr(data, "_attribute_map"): - constants = [name for name, config in getattr(data, '_validation', {}).items() - if config.get('constant')] + constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] try: for attr, mapconfig in data._attribute_map.items(): if attr in constants: @@ -1412,15 +1425,11 @@ def _deserialize(self, target_obj, data): value = getattr(data, attr) if value is None: continue - local_type = mapconfig['type'] - internal_data_type = local_type.strip('[]{}') + local_type = mapconfig["type"] + internal_data_type = local_type.strip("[]{}") if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): continue - setattr( - data, - attr, - self._deserialize(local_type, value) - ) + setattr(data, attr, self._deserialize(local_type, value)) return data except AttributeError: return @@ -1435,16 +1444,16 @@ def _deserialize(self, target_obj, data): if data is None: return data try: - attributes = response._attribute_map + attributes = response._attribute_map # type: ignore d_attrs = {} for attr, attr_desc in attributes.items(): # Check empty string. If it's not empty, someone has a real "additionalProperties"... - if attr == "additional_properties" and attr_desc["key"] == '': + if attr == "additional_properties" and attr_desc["key"] == "": continue raw_value = None # Enhance attr_desc with some dynamic data - attr_desc = attr_desc.copy() # Do a copy, do not change the real one - internal_data_type = attr_desc["type"].strip('[]{}') + attr_desc = attr_desc.copy() # Do a copy, do not change the real one + internal_data_type = attr_desc["type"].strip("[]{}") if internal_data_type in self.dependencies: attr_desc["internalType"] = self.dependencies[internal_data_type] @@ -1452,21 +1461,18 @@ def _deserialize(self, target_obj, data): found_value = key_extractor(attr, attr_desc, data) if found_value is not None: if raw_value is not None and raw_value != found_value: - msg = ("Ignoring extracted value '%s' from %s for key '%s'" - " (duplicate extraction, follow extractors order)" ) - _LOGGER.warning( - msg, - found_value, - key_extractor, - attr + msg = ( + "Ignoring extracted value '%s' from %s for key '%s'" + " (duplicate extraction, follow extractors order)" ) + _LOGGER.warning(msg, found_value, key_extractor, attr) continue raw_value = found_value - value = self.deserialize_data(raw_value, attr_desc['type']) + value = self.deserialize_data(raw_value, attr_desc["type"]) d_attrs[attr] = value except (AttributeError, TypeError, KeyError) as err: - msg = "Unable to deserialize to object: " + class_name + msg = "Unable to deserialize to object: " + class_name # type: ignore raise_with_traceback(DeserializationError, msg, err) else: additional_properties = self._build_additional_properties(attributes, data) @@ -1475,14 +1481,17 @@ def _deserialize(self, target_obj, data): def _build_additional_properties(self, attribute_map, data): if not self.additional_properties_detection: return None - if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != '': + if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != "": # Check empty string. If it's not empty, someone has a real "additionalProperties" return None if isinstance(data, ET.Element): data = {el.tag: el.text for el in data} - known_keys = {_decode_attribute_map_key(_FLATTEN.split(desc['key'])[0]) - for desc in attribute_map.values() if desc['key'] != ''} + known_keys = { + _decode_attribute_map_key(_FLATTEN.split(desc["key"])[0]) + for desc in attribute_map.values() + if desc["key"] != "" + } present_keys = set(data.keys()) missing_keys = present_keys - known_keys return {key: data[key] for key in missing_keys} @@ -1493,7 +1502,7 @@ def _classify_target(self, target, data): Once classification has been determined, initialize object. :param str target: The target object type to deserialize to. - :param str/dict data: The response data to deseralize. + :param str/dict data: The response data to deserialize. """ if target is None: return None, None @@ -1508,7 +1517,7 @@ def _classify_target(self, target, data): target = target._classify(data, self.dependencies) except AttributeError: pass # Target is not a Model, no classify - return target, target.__class__.__name__ + return target, target.__class__.__name__ # type: ignore def failsafe_deserialize(self, target_obj, data, content_type=None): """Ignores any errors encountered in deserialization, @@ -1518,15 +1527,14 @@ def failsafe_deserialize(self, target_obj, data, content_type=None): a deserialization error. :param str target_obj: The target object type to deserialize to. - :param str/dict data: The response data to deseralize. + :param str/dict data: The response data to deserialize. :param str content_type: Swagger "produces" if available. """ try: return self(target_obj, data, content_type=content_type) except: _LOGGER.debug( - "Ran into a deserialization error. Ignoring since this is failsafe deserialization", - exc_info=True + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True ) return None @@ -1554,22 +1562,16 @@ def _unpack_content(raw_data, content_type=None): return context[RawDeserializer.CONTEXT_NAME] raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") - #Assume this is enough to recognize universal_http.ClientResponse without importing it + # Assume this is enough to recognize universal_http.ClientResponse without importing it if hasattr(raw_data, "body"): - return RawDeserializer.deserialize_from_http_generics( - raw_data.text(), - raw_data.headers - ) + return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) # Assume this enough to recognize requests.Response without importing it. - if hasattr(raw_data, '_content_consumed'): - return RawDeserializer.deserialize_from_http_generics( - raw_data.text, - raw_data.headers - ) + if hasattr(raw_data, "_content_consumed"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) - if isinstance(raw_data, (basestring, bytes)) or hasattr(raw_data, 'read'): - return RawDeserializer.deserialize_from_text(raw_data, content_type) + if isinstance(raw_data, (basestring, bytes)) or hasattr(raw_data, "read"): + return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore return raw_data def _instantiate_model(self, response, attrs, additional_properties=None): @@ -1579,14 +1581,11 @@ def _instantiate_model(self, response, attrs, additional_properties=None): :param d_attrs: The deserialized response attributes. """ if callable(response): - subtype = getattr(response, '_subtype_map', {}) + subtype = getattr(response, "_subtype_map", {}) try: - readonly = [k for k, v in response._validation.items() - if v.get('readonly')] - const = [k for k, v in response._validation.items() - if v.get('constant')] - kwargs = {k: v for k, v in attrs.items() - if k not in subtype and k not in readonly + const} + readonly = [k for k, v in response._validation.items() if v.get("readonly")] + const = [k for k, v in response._validation.items() if v.get("constant")] + kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} response_obj = response(**kwargs) for attr in readonly: setattr(response_obj, attr, attrs.get(attr)) @@ -1594,8 +1593,7 @@ def _instantiate_model(self, response, attrs, additional_properties=None): response_obj.additional_properties = additional_properties return response_obj except TypeError as err: - msg = "Unable to deserialize {} into model {}. ".format( - kwargs, response) + msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore raise DeserializationError(msg + str(err)) else: try: @@ -1659,13 +1657,10 @@ def deserialize_iter(self, attr, iter_type): """ if attr is None: return None - if isinstance(attr, ET.Element): # If I receive an element here, get the children + if isinstance(attr, ET.Element): # If I receive an element here, get the children attr = list(attr) if not isinstance(attr, (list, set)): - raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format( - iter_type, - type(attr) - )) + raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(iter_type, type(attr))) return [self.deserialize_data(a, iter_type) for a in attr] def deserialize_dict(self, attr, dict_type): @@ -1677,7 +1672,7 @@ def deserialize_dict(self, attr, dict_type): :rtype: dict """ if isinstance(attr, list): - return {x['key']: self.deserialize_data(x['value'], dict_type) for x in attr} + return {x["key"]: self.deserialize_data(x["value"], dict_type) for x in attr} if isinstance(attr, ET.Element): # Transform value into {"Key": "value"} @@ -1698,7 +1693,7 @@ def deserialize_object(self, attr, **kwargs): # Do no recurse on XML, just return the tree as-is return attr if isinstance(attr, basestring): - return self.deserialize_basic(attr, 'str') + return self.deserialize_basic(attr, "str") obj_type = type(attr) if obj_type in self.basic_types: return self.deserialize_basic(attr, self.basic_types[obj_type]) @@ -1709,8 +1704,7 @@ def deserialize_object(self, attr, **kwargs): deserialized = {} for key, value in attr.items(): try: - deserialized[key] = self.deserialize_object( - value, **kwargs) + deserialized[key] = self.deserialize_object(value, **kwargs) except ValueError: deserialized[key] = None return deserialized @@ -1719,8 +1713,7 @@ def deserialize_object(self, attr, **kwargs): deserialized = [] for obj in attr: try: - deserialized.append(self.deserialize_object( - obj, **kwargs)) + deserialized.append(self.deserialize_object(obj, **kwargs)) except ValueError: pass return deserialized @@ -1747,23 +1740,23 @@ def deserialize_basic(self, attr, data_type): if not attr: if data_type == "str": # None or '', node is empty string. - return '' + return "" else: # None or '', node with a strong type is None. # Don't try to model "empty bool" or "empty int" return None - if data_type == 'bool': + if data_type == "bool": if attr in [True, False, 1, 0]: return bool(attr) elif isinstance(attr, basestring): - if attr.lower() in ['true', '1']: + if attr.lower() in ["true", "1"]: return True - elif attr.lower() in ['false', '0']: + elif attr.lower() in ["false", "0"]: return False raise TypeError("Invalid boolean value: {}".format(attr)) - if data_type == 'str': + if data_type == "str": return self.deserialize_unicode(attr) return eval(data_type)(attr) # nosec @@ -1782,7 +1775,7 @@ def deserialize_unicode(data): # Consider this is real string try: - if isinstance(data, unicode): + if isinstance(data, unicode): # type: ignore return data except NameError: return str(data) @@ -1833,7 +1826,7 @@ def deserialize_bytearray(attr): """ if isinstance(attr, ET.Element): attr = attr.text - return bytearray(b64decode(attr)) + return bytearray(b64decode(attr)) # type: ignore @staticmethod def deserialize_base64(attr): @@ -1845,9 +1838,9 @@ def deserialize_base64(attr): """ if isinstance(attr, ET.Element): attr = attr.text - padding = '=' * (3 - (len(attr) + 3) % 4) - attr = attr + padding - encoded = attr.replace('-', '+').replace('_', '/') + padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore + attr = attr + padding # type: ignore + encoded = attr.replace("-", "+").replace("_", "/") return b64decode(encoded) @staticmethod @@ -1861,7 +1854,7 @@ def deserialize_decimal(attr): if isinstance(attr, ET.Element): attr = attr.text try: - return decimal.Decimal(attr) + return decimal.Decimal(attr) # type: ignore except decimal.DecimalException as err: msg = "Invalid decimal {}".format(attr) raise_with_traceback(DeserializationError, msg, err) @@ -1876,7 +1869,7 @@ def deserialize_long(attr): """ if isinstance(attr, ET.Element): attr = attr.text - return _long_type(attr) + return _long_type(attr) # type: ignore @staticmethod def deserialize_duration(attr): @@ -1890,7 +1883,7 @@ def deserialize_duration(attr): attr = attr.text try: duration = isodate.parse_duration(attr) - except(ValueError, OverflowError, AttributeError) as err: + except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize duration object." raise_with_traceback(DeserializationError, msg, err) else: @@ -1906,7 +1899,7 @@ def deserialize_date(attr): """ if isinstance(attr, ET.Element): attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): + 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) @@ -1921,7 +1914,7 @@ def deserialize_time(attr): """ if isinstance(attr, ET.Element): attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): + if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore raise DeserializationError("Date must have only digits and -. Received: %s" % attr) return isodate.parse_time(attr) @@ -1936,10 +1929,9 @@ def deserialize_rfc(attr): if isinstance(attr, ET.Element): attr = attr.text try: - parsed_date = email.utils.parsedate_tz(attr) + parsed_date = email.utils.parsedate_tz(attr) # type: ignore date_obj = datetime.datetime( - *parsed_date[:6], - tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0)/60)) + *parsed_date[:6], tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) ) if not date_obj.tzinfo: date_obj = date_obj.astimezone(tz=TZ_UTC) @@ -1960,12 +1952,12 @@ def deserialize_iso(attr): if isinstance(attr, ET.Element): attr = attr.text try: - attr = attr.upper() + attr = attr.upper() # type: ignore match = Deserializer.valid_date.match(attr) if not match: raise ValueError("Invalid datetime string: " + attr) - check_decimal = attr.split('.') + check_decimal = attr.split(".") if len(check_decimal) > 1: decimal_str = "" for digit in check_decimal[1]: @@ -1980,7 +1972,7 @@ def deserialize_iso(attr): test_utc = date_obj.utctimetuple() if test_utc.tm_year > 9999 or test_utc.tm_year < 1: raise OverflowError("Hit max or min date") - except(ValueError, OverflowError, AttributeError) as err: + except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize datetime object." raise_with_traceback(DeserializationError, msg, err) else: @@ -1996,7 +1988,7 @@ def deserialize_unix(attr): :raises: DeserializationError if format invalid """ if isinstance(attr, ET.Element): - attr = int(attr.text) + attr = int(attr.text) # type: ignore try: date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) except ValueError as err: diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/_configuration.py index fdcdf086fd99..a1914da0a578 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/_configuration.py @@ -36,7 +36,7 @@ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - **kwargs # type: Any + **kwargs: Any ) -> None: if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/_monitor_management_client.py index bbd1d5889751..03f1774eecff 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/_monitor_management_client.py @@ -101,7 +101,7 @@ def __init__( api_version: Optional[str] = None, base_url: str = "https://management.azure.com", profile: KnownProfiles = KnownProfiles.default, - **kwargs # type: Any + **kwargs: Any ) -> None: self._config = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) @@ -145,6 +145,7 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 2021-09-01-preview: :mod:`v2022_02_01_preview.models` * 2022-04-01: :mod:`v2022_04_01.models` * 2022-06-01: :mod:`v2022_06_01.models` + * 2022-08-01-preview: :mod:`v2022_08_01_preview.models` * 2022-10-01: :mod:`v2022_10_01.models` """ if api_version == '2015-04-01': @@ -228,6 +229,9 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2022-06-01': from ..v2022_06_01 import models return models + elif api_version == '2022-08-01-preview': + from ..v2022_08_01_preview import models + return models elif api_version == '2022-10-01': from ..v2022_10_01 import models return models @@ -732,12 +736,15 @@ def scheduled_query_rules(self): * 2018-04-16: :class:`ScheduledQueryRulesOperations` * 2020-05-01-preview: :class:`ScheduledQueryRulesOperations` + * 2022-08-01-preview: :class:`ScheduledQueryRulesOperations` """ api_version = self._get_api_version('scheduled_query_rules') if api_version == '2018-04-16': from ..v2018_04_16.aio.operations import ScheduledQueryRulesOperations as OperationClass elif api_version == '2020-05-01-preview': from ..v2020_05_01_preview.aio.operations import ScheduledQueryRulesOperations as OperationClass + elif api_version == '2022-08-01-preview': + from ..v2022_08_01_preview.aio.operations import ScheduledQueryRulesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'scheduled_query_rules'".format(api_version)) self._config.api_version = api_version diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/__init__.py index 8ba4823444a9..2c7733bfd566 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/__init__.py @@ -13,12 +13,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["MonitorManagementClient"] +__all__ = [ + "MonitorManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_configuration.py index cdc7a049c1d9..84225ab1970a 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_configuration.py @@ -44,10 +44,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, **kwargs # type: Any - ): - # type: (...) -> None + def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_metadata.json index 32646c78f4e3..977b6fa08840 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_metadata.json @@ -19,13 +19,15 @@ "signature": "credential: \"TokenCredential\",", "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true + "required": true, + "method_location": "positional" }, "subscription_id": { "signature": "subscription_id: str,", "description": "The ID of the target subscription. Required.", "docstring_type": "str", - "required": true + "required": true, + "method_location": "positional" } }, "async": { @@ -48,22 +50,25 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "signature": "api_version: Optional[str]=None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } }, "async": { @@ -71,19 +76,22 @@ "signature": "api_version: Optional[str] = None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { "signature": "profile: KnownProfiles = KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } } } @@ -104,4 +112,4 @@ "tenant_activity_logs": "TenantActivityLogsOperations", "alert_rules": "AlertRulesOperations" } -} \ No newline at end of file +} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_monitor_management_client.py index 221fd063eb4c..fb2d5ceedaca 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_monitor_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from . import models +from . import models as _models from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ( @@ -67,7 +67,7 @@ def __init__( ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -106,15 +106,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> MonitorManagementClient + def __enter__(self) -> "MonitorManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_vendor.py index 9aad73fc743e..bd0df84f5319 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_vendor.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_vendor.py @@ -5,6 +5,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import List, cast + from azure.core.pipeline.transport import HttpRequest @@ -22,6 +24,7 @@ def _format_url_section(template, **kwargs): try: return template.format(**kwargs) except KeyError as key: - formatted_components = template.split("/") + # Need the cast, as for some reasons "split" is typed as list[str | Any] + formatted_components = cast(List[str], template.split("/")) components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_version.py index ce9ac7ae37b3..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/__init__.py index 8638dc69d869..2c151bb41c19 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/__init__.py @@ -10,12 +10,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["MonitorManagementClient"] +__all__ = [ + "MonitorManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/_monitor_management_client.py index e0c4dedc5c97..2aeead936cbf 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/_monitor_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from .. import models +from .. import models as _models from ..._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ( @@ -68,7 +68,7 @@ def __init__( ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -114,5 +114,5 @@ async def __aenter__(self) -> "MonitorManagementClient": await self._client.__aenter__() return self - async def __aexit__(self, *exc_details) -> None: + async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/__init__.py index 4c1cd2bf4a61..c3fc4cfffbbe 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/__init__.py @@ -14,7 +14,7 @@ from ._alert_rules_operations import AlertRulesOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_activity_logs_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_activity_logs_operations.py index 774da210f593..e6da854bf40d 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_activity_logs_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_activity_logs_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -28,6 +29,10 @@ from ..._vendor import _convert_request from ...operations._activity_logs_operations import build_list_request +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -88,8 +93,8 @@ def list(self, filter: str, select: Optional[str] = None, **kwargs: Any) -> Asyn _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.EventDataCollection] + api_version: Literal["2015-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) + cls: ClsType[_models.EventDataCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -112,12 +117,12 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -125,13 +130,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("EventDataCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -145,4 +150,4 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/eventtypes/management/values"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/eventtypes/management/values"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_alert_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_alert_rules_operations.py index 619efcdd584d..45acaee8579e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_alert_rules_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_alert_rules_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -36,6 +37,10 @@ build_update_request, ) +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -126,8 +131,8 @@ async def create_or_update( :type resource_group_name: str :param rule_name: The name of the rule. Required. :type rule_name: str - :param parameters: The parameters of the rule to create or update. Is either a model type or a - IO type. Required. + :param parameters: The parameters of the rule to create or update. Is either a + AlertRuleResource type or a IO type. Required. :type parameters: ~$(python-base-namespace).v2015_04_01.models.AlertRuleResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -148,9 +153,9 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResource] + api_version: Literal["2014-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AlertRuleResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -173,9 +178,9 @@ async def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -193,11 +198,13 @@ async def create_or_update( deserialized = self._deserialize("AlertRuleResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -226,8 +233,8 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2014-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -239,9 +246,9 @@ async def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -255,7 +262,9 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}" + } @distributed_trace_async async def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _models.AlertRuleResource: @@ -282,8 +291,8 @@ async def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResource] + api_version: Literal["2014-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) + cls: ClsType[_models.AlertRuleResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -295,9 +304,9 @@ async def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -315,7 +324,9 @@ async def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}" + } @overload async def update( @@ -391,8 +402,8 @@ async def update( :type resource_group_name: str :param rule_name: The name of the rule. Required. :type rule_name: str - :param alert_rules_resource: Parameters supplied to the operation. Is either a model type or a - IO type. Required. + :param alert_rules_resource: Parameters supplied to the operation. Is either a + AlertRuleResourcePatch type or a IO type. Required. :type alert_rules_resource: ~$(python-base-namespace).v2015_04_01.models.AlertRuleResourcePatch or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -414,9 +425,9 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResource] + api_version: Literal["2014-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AlertRuleResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -439,9 +450,9 @@ async def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -459,11 +470,13 @@ async def update( deserialized = self._deserialize("AlertRuleResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}" + } @distributed_trace def list_by_resource_group( @@ -483,8 +496,8 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResourceCollection] + api_version: Literal["2014-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) + cls: ClsType[_models.AlertRuleResourceCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -506,12 +519,12 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -519,13 +532,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("AlertRuleResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -539,7 +552,9 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules" + } @distributed_trace def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.AlertRuleResource"]: @@ -554,8 +569,8 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.AlertRul _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResourceCollection] + api_version: Literal["2014-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) + cls: ClsType[_models.AlertRuleResourceCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -576,12 +591,12 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -589,13 +604,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("AlertRuleResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -609,4 +624,4 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/alertrules"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/alertrules"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_autoscale_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_autoscale_settings_operations.py index 0228f46189ab..df8c3e053da5 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_autoscale_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_autoscale_settings_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -36,6 +37,10 @@ build_update_request, ) +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -78,8 +83,8 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.AutoscaleSettingResourceCollection] + api_version: Literal["2015-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) + cls: ClsType[_models.AutoscaleSettingResourceCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -101,12 +106,12 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -114,13 +119,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("AutoscaleSettingResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -134,7 +139,9 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings" + } @overload async def create_or_update( @@ -207,8 +214,8 @@ async def create_or_update( :type resource_group_name: str :param autoscale_setting_name: The autoscale setting name. Required. :type autoscale_setting_name: str - :param parameters: Parameters supplied to the operation. Is either a model type or a IO type. - Required. + :param parameters: Parameters supplied to the operation. Is either a AutoscaleSettingResource + type or a IO type. Required. :type parameters: ~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -229,9 +236,9 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.AutoscaleSettingResource] + api_version: Literal["2015-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AutoscaleSettingResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -254,9 +261,9 @@ async def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -274,11 +281,13 @@ async def create_or_update( deserialized = self._deserialize("AutoscaleSettingResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -307,8 +316,8 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2015-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -320,9 +329,9 @@ async def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -336,7 +345,9 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}" + } @distributed_trace_async async def get( @@ -365,8 +376,8 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.AutoscaleSettingResource] + api_version: Literal["2015-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) + cls: ClsType[_models.AutoscaleSettingResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -378,9 +389,9 @@ async def get( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -398,7 +409,9 @@ async def get( return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}" + } @overload async def update( @@ -475,8 +488,8 @@ async def update( :type resource_group_name: str :param autoscale_setting_name: The autoscale setting name. Required. :type autoscale_setting_name: str - :param autoscale_setting_resource: Parameters supplied to the operation. Is either a model type - or a IO type. Required. + :param autoscale_setting_resource: Parameters supplied to the operation. Is either a + AutoscaleSettingResourcePatch type or a IO type. Required. :type autoscale_setting_resource: ~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResourcePatch or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -498,9 +511,9 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.AutoscaleSettingResource] + api_version: Literal["2015-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AutoscaleSettingResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -523,9 +536,9 @@ async def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -543,7 +556,9 @@ async def update( return deserialized - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}" + } @distributed_trace def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.AutoscaleSettingResource"]: @@ -559,8 +574,8 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.Autoscal _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.AutoscaleSettingResourceCollection] + api_version: Literal["2015-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) + cls: ClsType[_models.AutoscaleSettingResourceCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -581,12 +596,12 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -594,13 +609,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("AutoscaleSettingResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -614,4 +629,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/autoscalesettings"} # type: ignore + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/autoscalesettings" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_event_categories_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_event_categories_operations.py index b2bcc2e99c17..d4a05d9e8132 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_event_categories_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_event_categories_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -28,6 +29,10 @@ from ..._vendor import _convert_request from ...operations._event_categories_operations import build_list_request +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -66,8 +71,8 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.LocalizableString"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.EventCategoryCollection] + api_version: Literal["2015-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) + cls: ClsType[_models.EventCategoryCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -87,12 +92,12 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -100,13 +105,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("EventCategoryCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -120,4 +125,4 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/providers/Microsoft.Insights/eventcategories"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Insights/eventcategories"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_operations.py index e940600d5183..50707d007d4f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -27,6 +28,10 @@ from ..._vendor import _convert_request from ...operations._operations import build_list_request +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -70,8 +75,8 @@ async def list(self, **kwargs: Any) -> _models.OperationListResult: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] + api_version: Literal["2015-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) request = build_list_request( api_version=api_version, @@ -80,9 +85,9 @@ async def list(self, **kwargs: Any) -> _models.OperationListResult: params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -99,4 +104,4 @@ async def list(self, **kwargs: Any) -> _models.OperationListResult: return deserialized - list.metadata = {"url": "/providers/Microsoft.Insights/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Insights/operations"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_tenant_activity_logs_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_tenant_activity_logs_operations.py index b197abc15cbf..030000f86a4d 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_tenant_activity_logs_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_tenant_activity_logs_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -28,6 +29,10 @@ from ..._vendor import _convert_request from ...operations._tenant_activity_logs_operations import build_list_request +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -95,8 +100,8 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.EventDataCollection] + api_version: Literal["2015-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) + cls: ClsType[_models.EventDataCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -118,12 +123,12 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -131,13 +136,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("EventDataCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -151,4 +156,4 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/providers/Microsoft.Insights/eventtypes/management/values"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Insights/eventtypes/management/values"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/__init__.py index 89233bd86942..3b949b4fe53a 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/__init__.py @@ -59,7 +59,7 @@ from ._monitor_management_client_enums import TimeAggregationOperator from ._monitor_management_client_enums import TimeAggregationType from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/_models_py3.py index 969ead3a7ab5..4124a44cb898 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/_models_py3.py @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, TYPE_CHECKING, Union +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union from ... import _serialization @@ -51,7 +51,7 @@ class Resource(_serialization.Model): "tags": {"key": "tags", "type": "{str}"}, } - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: """ :keyword location: Resource location. Required. :paramtype location: str @@ -142,8 +142,8 @@ def __init__( provisioning_state: Optional[str] = None, action: Optional["_models.RuleAction"] = None, actions: Optional[List["_models.RuleAction"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword location: Resource location. Required. :paramtype location: str @@ -189,7 +189,7 @@ class AlertRuleResourceCollection(_serialization.Model): "value": {"key": "value", "type": "[AlertRuleResource]"}, } - def __init__(self, *, value: Optional[List["_models.AlertRuleResource"]] = None, **kwargs): + def __init__(self, *, value: Optional[List["_models.AlertRuleResource"]] = None, **kwargs: Any) -> None: """ :keyword value: the values for the alert rule resources. :paramtype value: list[~$(python-base-namespace).v2015_04_01.models.AlertRuleResource] @@ -252,8 +252,8 @@ def __init__( condition: Optional["_models.RuleCondition"] = None, action: Optional["_models.RuleAction"] = None, actions: Optional[List["_models.RuleAction"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword tags: Resource tags. :paramtype tags: dict[str, str] @@ -320,8 +320,8 @@ def __init__( *, email: Optional["_models.EmailNotification"] = None, webhooks: Optional[List["_models.WebhookNotification"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword email: the email notification. :paramtype email: ~$(python-base-namespace).v2015_04_01.models.EmailNotification @@ -375,8 +375,8 @@ def __init__( rules: List["_models.ScaleRule"], fixed_date: Optional["_models.TimeWindow"] = None, recurrence: Optional["_models.Recurrence"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: the name of the profile. Required. :paramtype name: str @@ -469,8 +469,8 @@ def __init__( name_properties_name: Optional[str] = None, target_resource_uri: Optional[str] = None, target_resource_location: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword location: Resource location. Required. :paramtype location: str @@ -523,7 +523,9 @@ class AutoscaleSettingResourceCollection(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, *, value: List["_models.AutoscaleSettingResource"], next_link: Optional[str] = None, **kwargs): + def __init__( + self, *, value: List["_models.AutoscaleSettingResource"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword value: the values for the autoscale setting resources. Required. :paramtype value: list[~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResource] @@ -583,8 +585,8 @@ def __init__( name: Optional[str] = None, target_resource_uri: Optional[str] = None, target_resource_location: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword tags: Resource tags. :paramtype tags: dict[str, str] @@ -642,8 +644,8 @@ def __init__( send_to_subscription_administrator: bool = False, send_to_subscription_co_administrators: bool = False, custom_emails: Optional[List[str]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword send_to_subscription_administrator: a value indicating whether to send email to subscription administrator. @@ -675,7 +677,7 @@ class ErrorResponse(_serialization.Model): "message": {"key": "message", "type": "str"}, } - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: """ :keyword code: Error code. :paramtype code: str @@ -688,7 +690,8 @@ def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, class EventCategoryCollection(_serialization.Model): - """A collection of event categories. Currently possible values are: Administrative, Security, ServiceHealth, Alert, Recommendation, Policy. + """A collection of event categories. Currently possible values are: Administrative, Security, + ServiceHealth, Alert, Recommendation, Policy. All required parameters must be populated in order to send to Azure. @@ -704,7 +707,7 @@ class EventCategoryCollection(_serialization.Model): "value": {"key": "value", "type": "[LocalizableString]"}, } - def __init__(self, *, value: List["_models.LocalizableString"], **kwargs): + def __init__(self, *, value: List["_models.LocalizableString"], **kwargs: Any) -> None: """ :keyword value: the list that includes the Azure event categories. Required. :paramtype value: list[~$(python-base-namespace).v2015_04_01.models.LocalizableString] @@ -842,7 +845,7 @@ class EventData(_serialization.Model): # pylint: disable=too-many-instance-attr "tenant_id": {"key": "tenantId", "type": "str"}, } - def __init__(self, **kwargs): # pylint: disable=too-many-locals + def __init__(self, **kwargs: Any) -> None: # pylint: disable=too-many-locals """ """ super().__init__(**kwargs) self.authorization = None @@ -891,7 +894,7 @@ class EventDataCollection(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, *, value: List["_models.EventData"], next_link: Optional[str] = None, **kwargs): + def __init__(self, *, value: List["_models.EventData"], next_link: Optional[str] = None, **kwargs: Any) -> None: """ :keyword value: this list that includes the Azure audit logs. Required. :paramtype value: list[~$(python-base-namespace).v2015_04_01.models.EventData] @@ -930,8 +933,8 @@ def __init__( client_ip_address: Optional[str] = None, method: Optional[str] = None, uri: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword client_request_id: the client request id. :paramtype client_request_id: str @@ -969,7 +972,7 @@ class LocalizableString(_serialization.Model): "localized_value": {"key": "localizedValue", "type": "str"}, } - def __init__(self, *, value: str, localized_value: Optional[str] = None, **kwargs): + def __init__(self, *, value: str, localized_value: Optional[str] = None, **kwargs: Any) -> None: """ :keyword value: the invariant value. Required. :paramtype value: str @@ -1016,14 +1019,14 @@ class RuleCondition(_serialization.Model): } } - def __init__(self, *, data_source: Optional["_models.RuleDataSource"] = None, **kwargs): + def __init__(self, *, data_source: Optional["_models.RuleDataSource"] = None, **kwargs: Any) -> None: """ :keyword data_source: the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource. :paramtype data_source: ~$(python-base-namespace).v2015_04_01.models.RuleDataSource """ super().__init__(**kwargs) - self.odata_type = None # type: Optional[str] + self.odata_type: Optional[str] = None self.data_source = data_source @@ -1067,8 +1070,8 @@ def __init__( failed_location_count: int, data_source: Optional["_models.RuleDataSource"] = None, window_size: Optional[datetime.timedelta] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword data_source: the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource. @@ -1082,7 +1085,7 @@ def __init__( :paramtype failed_location_count: int """ super().__init__(data_source=data_source, **kwargs) - self.odata_type = "Microsoft.Azure.Management.Insights.Models.LocationThresholdRuleCondition" # type: str + self.odata_type: str = "Microsoft.Azure.Management.Insights.Models.LocationThresholdRuleCondition" self.window_size = window_size self.failed_location_count = failed_location_count @@ -1113,8 +1116,8 @@ def __init__( operator: Optional[Union[str, "_models.ConditionOperator"]] = None, threshold: Optional[float] = None, window_size: Optional[datetime.timedelta] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword operator: the condition operator. Known values are: "GreaterThan", "GreaterThanOrEqual", "LessThan", and "LessThanOrEqual". @@ -1167,8 +1170,8 @@ def __init__( *, data_source: Optional["_models.RuleDataSource"] = None, aggregation: Optional["_models.ManagementEventAggregationCondition"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword data_source: the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource. @@ -1180,7 +1183,7 @@ def __init__( ~$(python-base-namespace).v2015_04_01.models.ManagementEventAggregationCondition """ super().__init__(data_source=data_source, **kwargs) - self.odata_type = "Microsoft.Azure.Management.Insights.Models.ManagementEventRuleCondition" # type: str + self.odata_type: str = "Microsoft.Azure.Management.Insights.Models.ManagementEventRuleCondition" self.aggregation = aggregation @@ -1268,8 +1271,8 @@ def __init__( metric_resource_location: Optional[str] = None, dimensions: Optional[List["_models.ScaleRuleMetricDimension"]] = None, divide_per_instance: Optional[bool] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword metric_name: the name of the metric that defines what the rule monitors. Required. :paramtype metric_name: str @@ -1339,7 +1342,9 @@ class Operation(_serialization.Model): "display": {"key": "display", "type": "OperationDisplay"}, } - def __init__(self, *, name: Optional[str] = None, display: Optional["_models.OperationDisplay"] = None, **kwargs): + def __init__( + self, *, name: Optional[str] = None, display: Optional["_models.OperationDisplay"] = None, **kwargs: Any + ) -> None: """ :keyword name: Operation name: {provider}/{resource}/{operation}. :paramtype name: str @@ -1374,8 +1379,8 @@ def __init__( provider: Optional[str] = None, resource: Optional[str] = None, operation: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword provider: Service provider: Microsoft.Insights. :paramtype provider: str @@ -1391,7 +1396,8 @@ def __init__( class OperationListResult(_serialization.Model): - """Result of the request to list Microsoft.Insights operations. It contains a list of operations and a URL link to get the next set of results. + """Result of the request to list Microsoft.Insights operations. It contains a list of operations + and a URL link to get the next set of results. :ivar value: List of operations supported by the Microsoft.Insights provider. :vartype value: list[~$(python-base-namespace).v2015_04_01.models.Operation] @@ -1404,7 +1410,9 @@ class OperationListResult(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs): + def __init__( + self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword value: List of operations supported by the Microsoft.Insights provider. :paramtype value: list[~$(python-base-namespace).v2015_04_01.models.Operation] @@ -1417,7 +1425,8 @@ def __init__(self, *, value: Optional[List["_models.Operation"]] = None, next_li class Recurrence(_serialization.Model): - """The repeating times at which this profile begins. This element is not used if the FixedDate element is used. + """The repeating times at which this profile begins. This element is not used if the FixedDate + element is used. All required parameters must be populated in order to send to Azure. @@ -1442,8 +1451,12 @@ class Recurrence(_serialization.Model): } def __init__( - self, *, frequency: Union[str, "_models.RecurrenceFrequency"], schedule: "_models.RecurrentSchedule", **kwargs - ): + self, + *, + frequency: Union[str, "_models.RecurrenceFrequency"], + schedule: "_models.RecurrentSchedule", + **kwargs: Any + ) -> None: """ :keyword frequency: the recurrence frequency. How often the schedule profile should take effect. This value must be Week, meaning each week will have the same set of profiles. For @@ -1519,7 +1532,7 @@ class RecurrentSchedule(_serialization.Model): "minutes": {"key": "minutes", "type": "[int]"}, } - def __init__(self, *, time_zone: str, days: List[str], hours: List[int], minutes: List[int], **kwargs): + def __init__(self, *, time_zone: str, days: List[str], hours: List[int], minutes: List[int], **kwargs: Any) -> None: """ :keyword time_zone: the timezone for the hours of the profile. Some examples of valid time zones are: Dateline Standard Time, UTC-11, Hawaiian Standard Time, Alaskan Standard Time, @@ -1569,7 +1582,8 @@ def __init__(self, *, time_zone: str, days: List[str], hours: List[int], minutes class RuleAction(_serialization.Model): - """The action that is performed when the alert rule becomes active, and when an alert condition is resolved. + """The action that is performed when the alert rule becomes active, and when an alert condition is + resolved. You probably want to use the sub-classes and not this class directly. Known sub-classes are: RuleEmailAction, RuleWebhookAction @@ -1596,10 +1610,10 @@ class RuleAction(_serialization.Model): } } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.odata_type = None # type: Optional[str] + self.odata_type: Optional[str] = None class RuleDataSource(_serialization.Model): @@ -1651,8 +1665,8 @@ def __init__( legacy_resource_id: Optional[str] = None, resource_location: Optional[str] = None, metric_namespace: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : this property cannot be updated for an existing rule. @@ -1666,7 +1680,7 @@ def __init__( :paramtype metric_namespace: str """ super().__init__(**kwargs) - self.odata_type = None # type: Optional[str] + self.odata_type: Optional[str] = None self.resource_uri = resource_uri self.legacy_resource_id = legacy_resource_id self.resource_location = resource_location @@ -1674,7 +1688,8 @@ def __init__( class RuleEmailAction(RuleAction): - """Specifies the action to send email when the rule condition is evaluated. The discriminator is always RuleEmailAction in this case. + """Specifies the action to send email when the rule condition is evaluated. The discriminator is + always RuleEmailAction in this case. All required parameters must be populated in order to send to Azure. @@ -1700,8 +1715,8 @@ class RuleEmailAction(RuleAction): } def __init__( - self, *, send_to_service_owners: Optional[bool] = None, custom_emails: Optional[List[str]] = None, **kwargs - ): + self, *, send_to_service_owners: Optional[bool] = None, custom_emails: Optional[List[str]] = None, **kwargs: Any + ) -> None: """ :keyword send_to_service_owners: Whether the administrators (service and co-administrators) of the service should be notified when the alert is activated. @@ -1711,7 +1726,7 @@ def __init__( :paramtype custom_emails: list[str] """ super().__init__(**kwargs) - self.odata_type = "Microsoft.Azure.Management.Insights.Models.RuleEmailAction" # type: str + self.odata_type: str = "Microsoft.Azure.Management.Insights.Models.RuleEmailAction" self.send_to_service_owners = send_to_service_owners self.custom_emails = custom_emails @@ -1727,7 +1742,7 @@ class RuleManagementEventClaimsDataSource(_serialization.Model): "email_address": {"key": "emailAddress", "type": "str"}, } - def __init__(self, *, email_address: Optional[str] = None, **kwargs): + def __init__(self, *, email_address: Optional[str] = None, **kwargs: Any) -> None: """ :keyword email_address: the email address. :paramtype email_address: str @@ -1737,7 +1752,8 @@ def __init__(self, *, email_address: Optional[str] = None, **kwargs): class RuleManagementEventDataSource(RuleDataSource): # pylint: disable=too-many-instance-attributes - """A rule management event data source. The discriminator fields is always RuleManagementEventDataSource in this case. + """A rule management event data source. The discriminator fields is always + RuleManagementEventDataSource in this case. All required parameters must be populated in order to send to Azure. @@ -1814,8 +1830,8 @@ def __init__( status: Optional[str] = None, sub_status: Optional[str] = None, claims: Optional["_models.RuleManagementEventClaimsDataSource"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : this property cannot be updated for an existing rule. @@ -1856,7 +1872,7 @@ def __init__( metric_namespace=metric_namespace, **kwargs ) - self.odata_type = "Microsoft.Azure.Management.Insights.Models.RuleManagementEventDataSource" # type: str + self.odata_type: str = "Microsoft.Azure.Management.Insights.Models.RuleManagementEventDataSource" self.event_name = event_name self.event_source = event_source self.level = level @@ -1911,8 +1927,8 @@ def __init__( resource_location: Optional[str] = None, metric_namespace: Optional[str] = None, metric_name: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : this property cannot be updated for an existing rule. @@ -1934,12 +1950,13 @@ def __init__( metric_namespace=metric_namespace, **kwargs ) - self.odata_type = "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource" # type: str + self.odata_type: str = "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource" self.metric_name = metric_name class RuleWebhookAction(RuleAction): - """Specifies the action to post to service when the rule condition is evaluated. The discriminator is always RuleWebhookAction in this case. + """Specifies the action to post to service when the rule condition is evaluated. The discriminator + is always RuleWebhookAction in this case. All required parameters must be populated in order to send to Azure. @@ -1964,7 +1981,9 @@ class RuleWebhookAction(RuleAction): "properties": {"key": "properties", "type": "{str}"}, } - def __init__(self, *, service_uri: Optional[str] = None, properties: Optional[Dict[str, str]] = None, **kwargs): + def __init__( + self, *, service_uri: Optional[str] = None, properties: Optional[Dict[str, str]] = None, **kwargs: Any + ) -> None: """ :keyword service_uri: the service uri to Post the notification when the alert activates or resolves. @@ -1974,7 +1993,7 @@ def __init__(self, *, service_uri: Optional[str] = None, properties: Optional[Di :paramtype properties: dict[str, str] """ super().__init__(**kwargs) - self.odata_type = "Microsoft.Azure.Management.Insights.Models.RuleWebhookAction" # type: str + self.odata_type: str = "Microsoft.Azure.Management.Insights.Models.RuleWebhookAction" self.service_uri = service_uri self.properties = properties @@ -2018,8 +2037,8 @@ def __init__( type: Union[str, "_models.ScaleType"], cooldown: datetime.timedelta, value: str = "1", - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword direction: the scale direction. Whether the scaling action increases or decreases the number of instances. Required. Known values are: "None", "Increase", and "Decrease". @@ -2069,7 +2088,7 @@ class ScaleCapacity(_serialization.Model): "default": {"key": "default", "type": "str"}, } - def __init__(self, *, minimum: str, maximum: str, default: str, **kwargs): + def __init__(self, *, minimum: str, maximum: str, default: str, **kwargs: Any) -> None: """ :keyword minimum: the minimum number of instances for the resource. Required. :paramtype minimum: str @@ -2108,7 +2127,9 @@ class ScaleRule(_serialization.Model): "scale_action": {"key": "scaleAction", "type": "ScaleAction"}, } - def __init__(self, *, metric_trigger: "_models.MetricTrigger", scale_action: "_models.ScaleAction", **kwargs): + def __init__( + self, *, metric_trigger: "_models.MetricTrigger", scale_action: "_models.ScaleAction", **kwargs: Any + ) -> None: """ :keyword metric_trigger: the trigger that results in a scaling action. Required. :paramtype metric_trigger: ~$(python-base-namespace).v2015_04_01.models.MetricTrigger @@ -2154,8 +2175,8 @@ def __init__( dimension_name: str, operator: Union[str, "_models.ScaleRuleMetricDimensionOperationType"], values: List[str], - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword dimension_name: Name of the dimension. Required. :paramtype dimension_name: str @@ -2174,7 +2195,9 @@ def __init__( class SenderAuthorization(_serialization.Model): - """the authorization used by the user who has performed the operation that led to this event. This captures the RBAC properties of the event. These usually include the 'action', 'role' and the 'scope'. + """the authorization used by the user who has performed the operation that led to this event. This + captures the RBAC properties of the event. These usually include the 'action', 'role' and the + 'scope'. :ivar action: the permissible actions. For instance: microsoft.support/supporttickets/write. :vartype action: str @@ -2191,8 +2214,8 @@ class SenderAuthorization(_serialization.Model): } def __init__( - self, *, action: Optional[str] = None, role: Optional[str] = None, scope: Optional[str] = None, **kwargs - ): + self, *, action: Optional[str] = None, role: Optional[str] = None, scope: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword action: the permissible actions. For instance: microsoft.support/supporttickets/write. :paramtype action: str @@ -2259,8 +2282,8 @@ def __init__( data_source: Optional["_models.RuleDataSource"] = None, window_size: Optional[datetime.timedelta] = None, time_aggregation: Optional[Union[str, "_models.TimeAggregationOperator"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword data_source: the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource. @@ -2281,7 +2304,7 @@ def __init__( ~$(python-base-namespace).v2015_04_01.models.TimeAggregationOperator """ super().__init__(data_source=data_source, **kwargs) - self.odata_type = "Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition" # type: str + self.odata_type: str = "Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition" self.operator = operator self.threshold = threshold self.window_size = window_size @@ -2341,7 +2364,9 @@ class TimeWindow(_serialization.Model): "end": {"key": "end", "type": "iso-8601"}, } - def __init__(self, *, start: datetime.datetime, end: datetime.datetime, time_zone: Optional[str] = None, **kwargs): + def __init__( + self, *, start: datetime.datetime, end: datetime.datetime, time_zone: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword time_zone: the timezone of the start and end times for the profile. Some examples of valid time zones are: Dateline Standard Time, UTC-11, Hawaiian Standard Time, Alaskan Standard @@ -2399,7 +2424,9 @@ class WebhookNotification(_serialization.Model): "properties": {"key": "properties", "type": "{str}"}, } - def __init__(self, *, service_uri: Optional[str] = None, properties: Optional[Dict[str, str]] = None, **kwargs): + def __init__( + self, *, service_uri: Optional[str] = None, properties: Optional[Dict[str, str]] = None, **kwargs: Any + ) -> None: """ :keyword service_uri: the service address to receive the notification. :paramtype service_uri: str diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/__init__.py index 4c1cd2bf4a61..c3fc4cfffbbe 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/__init__.py @@ -14,7 +14,7 @@ from ._alert_rules_operations import AlertRulesOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_activity_logs_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_activity_logs_operations.py index 8e8230430e82..f04898813bd1 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_activity_logs_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_activity_logs_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar from azure.core.exceptions import ( @@ -28,6 +29,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -41,7 +46,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str + api_version: Literal["2015-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -52,7 +57,7 @@ def build_list_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -121,8 +126,8 @@ def list(self, filter: str, select: Optional[str] = None, **kwargs: Any) -> Iter _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.EventDataCollection] + api_version: Literal["2015-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) + cls: ClsType[_models.EventDataCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -145,12 +150,12 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -158,13 +163,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("EventDataCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -178,4 +183,4 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/eventtypes/management/values"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/eventtypes/management/values"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_alert_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_alert_rules_operations.py index 55ed2f71b401..3832e82227e5 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_alert_rules_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_alert_rules_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -28,6 +29,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -41,8 +46,8 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2014-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -58,7 +63,7 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -75,7 +80,7 @@ def build_delete_request(resource_group_name: str, rule_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str + api_version: Literal["2014-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -91,7 +96,7 @@ def build_delete_request(resource_group_name: str, rule_name: str, subscription_ "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -106,7 +111,7 @@ def build_get_request(resource_group_name: str, rule_name: str, subscription_id: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str + api_version: Literal["2014-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -122,7 +127,7 @@ def build_get_request(resource_group_name: str, rule_name: str, subscription_id: "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -137,8 +142,8 @@ def build_update_request(resource_group_name: str, rule_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2014-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -154,7 +159,7 @@ def build_update_request(resource_group_name: str, rule_name: str, subscription_ "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -171,7 +176,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str + api_version: Literal["2014-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -186,7 +191,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -201,7 +206,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str + api_version: Literal["2014-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -210,7 +215,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -307,8 +312,8 @@ def create_or_update( :type resource_group_name: str :param rule_name: The name of the rule. Required. :type rule_name: str - :param parameters: The parameters of the rule to create or update. Is either a model type or a - IO type. Required. + :param parameters: The parameters of the rule to create or update. Is either a + AlertRuleResource type or a IO type. Required. :type parameters: ~$(python-base-namespace).v2015_04_01.models.AlertRuleResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -329,9 +334,9 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResource] + api_version: Literal["2014-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AlertRuleResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -354,9 +359,9 @@ def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -374,11 +379,13 @@ def create_or_update( deserialized = self._deserialize("AlertRuleResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -407,8 +414,8 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2014-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -420,9 +427,9 @@ def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -436,7 +443,9 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}" + } @distributed_trace def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _models.AlertRuleResource: @@ -463,8 +472,8 @@ def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _model _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResource] + api_version: Literal["2014-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) + cls: ClsType[_models.AlertRuleResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -476,9 +485,9 @@ def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _model params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -496,7 +505,9 @@ def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _model return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}" + } @overload def update( @@ -572,8 +583,8 @@ def update( :type resource_group_name: str :param rule_name: The name of the rule. Required. :type rule_name: str - :param alert_rules_resource: Parameters supplied to the operation. Is either a model type or a - IO type. Required. + :param alert_rules_resource: Parameters supplied to the operation. Is either a + AlertRuleResourcePatch type or a IO type. Required. :type alert_rules_resource: ~$(python-base-namespace).v2015_04_01.models.AlertRuleResourcePatch or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -595,9 +606,9 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResource] + api_version: Literal["2014-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AlertRuleResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -620,9 +631,9 @@ def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -640,11 +651,13 @@ def update( deserialized = self._deserialize("AlertRuleResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}" + } @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.AlertRuleResource"]: @@ -662,8 +675,8 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResourceCollection] + api_version: Literal["2014-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) + cls: ClsType[_models.AlertRuleResourceCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -685,12 +698,12 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -698,13 +711,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("AlertRuleResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -718,7 +731,9 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules" + } @distributed_trace def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.AlertRuleResource"]: @@ -733,8 +748,8 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.AlertRuleReso _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResourceCollection] + api_version: Literal["2014-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) + cls: ClsType[_models.AlertRuleResourceCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -755,12 +770,12 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -768,13 +783,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("AlertRuleResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -788,4 +803,4 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/alertrules"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/alertrules"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_autoscale_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_autoscale_settings_operations.py index e1bb6041118a..6131bea348ec 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_autoscale_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_autoscale_settings_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -28,6 +29,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -39,7 +44,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str + api_version: Literal["2015-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -54,7 +59,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -71,8 +76,8 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2015-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -88,7 +93,7 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -107,7 +112,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str + api_version: Literal["2015-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -123,7 +128,7 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -140,7 +145,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str + api_version: Literal["2015-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -156,7 +161,7 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -173,8 +178,8 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2015-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -190,7 +195,7 @@ def build_update_request( "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -207,7 +212,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str + api_version: Literal["2015-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -216,7 +221,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -265,8 +270,8 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.AutoscaleSettingResourceCollection] + api_version: Literal["2015-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) + cls: ClsType[_models.AutoscaleSettingResourceCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -288,12 +293,12 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -301,13 +306,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("AutoscaleSettingResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -321,7 +326,9 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings" + } @overload def create_or_update( @@ -394,8 +401,8 @@ def create_or_update( :type resource_group_name: str :param autoscale_setting_name: The autoscale setting name. Required. :type autoscale_setting_name: str - :param parameters: Parameters supplied to the operation. Is either a model type or a IO type. - Required. + :param parameters: Parameters supplied to the operation. Is either a AutoscaleSettingResource + type or a IO type. Required. :type parameters: ~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -416,9 +423,9 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.AutoscaleSettingResource] + api_version: Literal["2015-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AutoscaleSettingResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -441,9 +448,9 @@ def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -461,11 +468,13 @@ def create_or_update( deserialized = self._deserialize("AutoscaleSettingResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -494,8 +503,8 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2015-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -507,9 +516,9 @@ def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -523,7 +532,9 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}" + } @distributed_trace def get( @@ -552,8 +563,8 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.AutoscaleSettingResource] + api_version: Literal["2015-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) + cls: ClsType[_models.AutoscaleSettingResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -565,9 +576,9 @@ def get( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -585,7 +596,9 @@ def get( return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}" + } @overload def update( @@ -662,8 +675,8 @@ def update( :type resource_group_name: str :param autoscale_setting_name: The autoscale setting name. Required. :type autoscale_setting_name: str - :param autoscale_setting_resource: Parameters supplied to the operation. Is either a model type - or a IO type. Required. + :param autoscale_setting_resource: Parameters supplied to the operation. Is either a + AutoscaleSettingResourcePatch type or a IO type. Required. :type autoscale_setting_resource: ~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResourcePatch or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -685,9 +698,9 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.AutoscaleSettingResource] + api_version: Literal["2015-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AutoscaleSettingResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -710,9 +723,9 @@ def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -730,7 +743,9 @@ def update( return deserialized - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}" + } @distributed_trace def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.AutoscaleSettingResource"]: @@ -746,8 +761,8 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.AutoscaleSett _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.AutoscaleSettingResourceCollection] + api_version: Literal["2015-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) + cls: ClsType[_models.AutoscaleSettingResourceCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -768,12 +783,12 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -781,13 +796,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("AutoscaleSettingResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -801,4 +816,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/autoscalesettings"} # type: ignore + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/autoscalesettings" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_event_categories_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_event_categories_operations.py index dace9d98b892..6dec6e05d2b0 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_event_categories_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_event_categories_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar from azure.core.exceptions import ( @@ -28,6 +29,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -39,7 +44,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 = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str + api_version: Literal["2015-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -88,8 +93,8 @@ def list(self, **kwargs: Any) -> Iterable["_models.LocalizableString"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.EventCategoryCollection] + api_version: Literal["2015-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) + cls: ClsType[_models.EventCategoryCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -109,12 +114,12 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -122,13 +127,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("EventCategoryCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -142,4 +147,4 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/providers/Microsoft.Insights/eventcategories"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Insights/eventcategories"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_operations.py index 0ccec89dc128..6f4fcbe5ec8c 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -27,6 +28,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -38,7 +43,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 = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str + api_version: Literal["2015-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -92,8 +97,8 @@ def list(self, **kwargs: Any) -> _models.OperationListResult: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] + api_version: Literal["2015-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) request = build_list_request( api_version=api_version, @@ -102,9 +107,9 @@ def list(self, **kwargs: Any) -> _models.OperationListResult: params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -121,4 +126,4 @@ def list(self, **kwargs: Any) -> _models.OperationListResult: return deserialized - list.metadata = {"url": "/providers/Microsoft.Insights/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Insights/operations"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_tenant_activity_logs_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_tenant_activity_logs_operations.py index cb9e5a5606a8..3bf0e3adf500 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_tenant_activity_logs_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_tenant_activity_logs_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar from azure.core.exceptions import ( @@ -28,6 +29,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -39,7 +44,7 @@ def build_list_request(*, filter: Optional[str] = None, select: Optional[str] = _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str + api_version: Literal["2015-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -120,8 +125,8 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.EventDataCollection] + api_version: Literal["2015-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-04-01")) + cls: ClsType[_models.EventDataCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -143,12 +148,12 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -156,13 +161,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("EventDataCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -176,4 +181,4 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/providers/Microsoft.Insights/eventtypes/management/values"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Insights/eventtypes/management/values"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/__init__.py index 8ba4823444a9..2c7733bfd566 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/__init__.py @@ -13,12 +13,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["MonitorManagementClient"] +__all__ = [ + "MonitorManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_configuration.py index cdc7a049c1d9..84225ab1970a 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_configuration.py @@ -44,10 +44,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, **kwargs # type: Any - ): - # type: (...) -> None + def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_metadata.json index 46482e0e8abd..9a7ac678d6b9 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_metadata.json @@ -19,13 +19,15 @@ "signature": "credential: \"TokenCredential\",", "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true + "required": true, + "method_location": "positional" }, "subscription_id": { "signature": "subscription_id: str,", "description": "The ID of the target subscription. Required.", "docstring_type": "str", - "required": true + "required": true, + "method_location": "positional" } }, "async": { @@ -48,22 +50,25 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "signature": "api_version: Optional[str]=None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } }, "async": { @@ -71,19 +76,22 @@ "signature": "api_version: Optional[str] = None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { "signature": "profile: KnownProfiles = KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } } } @@ -102,4 +110,4 @@ "alert_rules": "AlertRulesOperations", "operations": "Operations" } -} \ No newline at end of file +} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_monitor_management_client.py index 11332bfbd51d..00fa828c6239 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_monitor_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from . import models +from . import models as _models from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ( @@ -60,7 +60,7 @@ def __init__( ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -95,15 +95,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> MonitorManagementClient + def __enter__(self) -> "MonitorManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_vendor.py index 9aad73fc743e..bd0df84f5319 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_vendor.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_vendor.py @@ -5,6 +5,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import List, cast + from azure.core.pipeline.transport import HttpRequest @@ -22,6 +24,7 @@ def _format_url_section(template, **kwargs): try: return template.format(**kwargs) except KeyError as key: - formatted_components = template.split("/") + # Need the cast, as for some reasons "split" is typed as list[str | Any] + formatted_components = cast(List[str], template.split("/")) components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_version.py index ce9ac7ae37b3..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/__init__.py index 8638dc69d869..2c151bb41c19 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/__init__.py @@ -10,12 +10,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["MonitorManagementClient"] +__all__ = [ + "MonitorManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/_monitor_management_client.py index 32eb44131780..22891e3ce00e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/_monitor_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from .. import models +from .. import models as _models from ..._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ( @@ -60,7 +60,7 @@ def __init__( ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -102,5 +102,5 @@ async def __aenter__(self) -> "MonitorManagementClient": await self._client.__aenter__() return self - async def __aexit__(self, *exc_details) -> None: + async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/__init__.py index 5737890365bd..acff6da37ac2 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/__init__.py @@ -12,7 +12,7 @@ from ._operations import Operations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_alert_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_alert_rules_operations.py index 2b1616605553..e95acb95f633 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_alert_rules_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_alert_rules_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -36,6 +37,10 @@ build_update_request, ) +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -126,8 +131,8 @@ async def create_or_update( :type resource_group_name: str :param rule_name: The name of the rule. Required. :type rule_name: str - :param parameters: The parameters of the rule to create or update. Is either a model type or a - IO type. Required. + :param parameters: The parameters of the rule to create or update. Is either a + AlertRuleResource type or a IO type. Required. :type parameters: ~$(python-base-namespace).v2015_07_01.models.AlertRuleResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -148,9 +153,9 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResource] + api_version: Literal["2014-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AlertRuleResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -173,9 +178,9 @@ async def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -193,11 +198,13 @@ async def create_or_update( deserialized = self._deserialize("AlertRuleResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -226,8 +233,8 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2014-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -239,9 +246,9 @@ async def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -255,7 +262,9 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}" + } @distributed_trace_async async def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _models.AlertRuleResource: @@ -282,8 +291,8 @@ async def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResource] + api_version: Literal["2014-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) + cls: ClsType[_models.AlertRuleResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -295,9 +304,9 @@ async def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -315,7 +324,9 @@ async def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}" + } @overload async def update( @@ -391,8 +402,8 @@ async def update( :type resource_group_name: str :param rule_name: The name of the rule. Required. :type rule_name: str - :param alert_rules_resource: Parameters supplied to the operation. Is either a model type or a - IO type. Required. + :param alert_rules_resource: Parameters supplied to the operation. Is either a + AlertRuleResourcePatch type or a IO type. Required. :type alert_rules_resource: ~$(python-base-namespace).v2015_07_01.models.AlertRuleResourcePatch or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -414,9 +425,9 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResource] + api_version: Literal["2014-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AlertRuleResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -439,9 +450,9 @@ async def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -459,11 +470,13 @@ async def update( deserialized = self._deserialize("AlertRuleResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}" + } @distributed_trace def list_by_resource_group( @@ -483,8 +496,8 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResourceCollection] + api_version: Literal["2014-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) + cls: ClsType[_models.AlertRuleResourceCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -506,12 +519,12 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -519,13 +532,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("AlertRuleResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -539,7 +552,9 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules" + } @distributed_trace def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.AlertRuleResource"]: @@ -554,8 +569,8 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.AlertRul _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResourceCollection] + api_version: Literal["2014-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) + cls: ClsType[_models.AlertRuleResourceCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -576,12 +591,12 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -589,13 +604,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("AlertRuleResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -609,4 +624,4 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/alertrules"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/alertrules"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_metric_definitions_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_metric_definitions_operations.py index 0bdb8e13d37f..a413e44a0a3b 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_metric_definitions_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_metric_definitions_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -28,6 +29,10 @@ from ..._vendor import _convert_request from ...operations._metric_definitions_operations import build_list_request +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -75,8 +80,8 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricDefinitionCollection] + api_version: Literal["2015-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) + cls: ClsType[_models.MetricDefinitionCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -98,12 +103,12 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -111,13 +116,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("MetricDefinitionCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -131,4 +136,4 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/metricDefinitions"} # type: ignore + list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/metricDefinitions"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_operations.py index dc726ea7dd97..737aee2673ec 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -27,6 +28,10 @@ from ..._vendor import _convert_request from ...operations._operations import build_list_request +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -70,8 +75,8 @@ async def list(self, **kwargs: Any) -> _models.OperationListResult: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] + api_version: Literal["2015-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) request = build_list_request( api_version=api_version, @@ -80,9 +85,9 @@ async def list(self, **kwargs: Any) -> _models.OperationListResult: params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -100,4 +105,4 @@ async def list(self, **kwargs: Any) -> _models.OperationListResult: return deserialized - list.metadata = {"url": "/providers/Microsoft.Insights/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Insights/operations"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_service_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_service_diagnostic_settings_operations.py index 1762e32db70b..7155bd7673c3 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_service_diagnostic_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_service_diagnostic_settings_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -27,6 +28,10 @@ from ..._vendor import _convert_request from ...operations._service_diagnostic_settings_operations import build_create_or_update_request, build_get_request +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -72,8 +77,8 @@ async def get(self, resource_uri: str, **kwargs: Any) -> _models.ServiceDiagnost _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceDiagnosticSettingsResource] + api_version: Literal["2015-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) + cls: ClsType[_models.ServiceDiagnosticSettingsResource] = kwargs.pop("cls", None) request = build_get_request( resource_uri=resource_uri, @@ -83,9 +88,9 @@ async def get(self, resource_uri: str, **kwargs: Any) -> _models.ServiceDiagnost params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -103,7 +108,7 @@ async def get(self, resource_uri: str, **kwargs: Any) -> _models.ServiceDiagnost return deserialized - get.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service"} # type: ignore + get.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service"} @overload async def create_or_update( @@ -157,8 +162,8 @@ async def create_or_update( :param resource_uri: The identifier of the resource. Required. :type resource_uri: str - :param parameters: Parameters supplied to the operation. Is either a model type or a IO type. - Required. + :param parameters: Parameters supplied to the operation. Is either a + ServiceDiagnosticSettingsResource type or a IO type. Required. :type parameters: ~$(python-base-namespace).v2015_07_01.models.ServiceDiagnosticSettingsResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -180,9 +185,9 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceDiagnosticSettingsResource] + api_version: Literal["2015-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ServiceDiagnosticSettingsResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -203,9 +208,9 @@ async def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -222,4 +227,4 @@ async def create_or_update( return deserialized - create_or_update.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service"} # type: ignore + create_or_update.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/__init__.py index f67e14597faa..20372e4e30d8 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/__init__.py @@ -47,7 +47,7 @@ from ._monitor_management_client_enums import TimeAggregationOperator from ._monitor_management_client_enums import Unit from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/_models_py3.py index 9d9565b0d7a6..f9b0a8b41d11 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/_models_py3.py @@ -13,13 +13,14 @@ from ... import _serialization -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models if sys.version_info >= (3, 9): from collections.abc import MutableMapping else: from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object @@ -57,7 +58,7 @@ class Resource(_serialization.Model): "tags": {"key": "tags", "type": "{str}"}, } - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: """ :keyword location: Resource location. Required. :paramtype location: str @@ -148,8 +149,8 @@ def __init__( provisioning_state: Optional[str] = None, action: Optional["_models.RuleAction"] = None, actions: Optional[List["_models.RuleAction"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword location: Resource location. Required. :paramtype location: str @@ -195,7 +196,7 @@ class AlertRuleResourceCollection(_serialization.Model): "value": {"key": "value", "type": "[AlertRuleResource]"}, } - def __init__(self, *, value: Optional[List["_models.AlertRuleResource"]] = None, **kwargs): + def __init__(self, *, value: Optional[List["_models.AlertRuleResource"]] = None, **kwargs: Any) -> None: """ :keyword value: the values for the alert rule resources. :paramtype value: list[~$(python-base-namespace).v2015_07_01.models.AlertRuleResource] @@ -258,8 +259,8 @@ def __init__( condition: Optional["_models.RuleCondition"] = None, action: Optional["_models.RuleAction"] = None, actions: Optional[List["_models.RuleAction"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword tags: Resource tags. :paramtype tags: dict[str, str] @@ -326,8 +327,8 @@ def __init__( to_be_exported_for_shoebox: Optional[bool] = None, is_hidden: Optional[bool] = None, default_dimension_values: Optional[JSON] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: Name of dimension. :paramtype name: str @@ -351,7 +352,8 @@ def __init__( class ErrorContract(_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.). + """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: ~$(python-base-namespace).v2015_07_01.models.ErrorResponse @@ -361,7 +363,7 @@ class ErrorContract(_serialization.Model): "error": {"key": "error", "type": "ErrorResponse"}, } - def __init__(self, *, error: Optional["_models.ErrorResponse"] = None, **kwargs): + def __init__(self, *, error: Optional["_models.ErrorResponse"] = None, **kwargs: Any) -> None: """ :keyword error: The error object. :paramtype error: ~$(python-base-namespace).v2015_07_01.models.ErrorResponse @@ -384,7 +386,7 @@ class ErrorResponse(_serialization.Model): "message": {"key": "message", "type": "str"}, } - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: """ :keyword code: Error code. :paramtype code: str @@ -416,7 +418,7 @@ class LocalizableString(_serialization.Model): "localized_value": {"key": "localizedValue", "type": "str"}, } - def __init__(self, *, value: str, localized_value: Optional[str] = None, **kwargs): + def __init__(self, *, value: str, localized_value: Optional[str] = None, **kwargs: Any) -> None: """ :keyword value: the invariant value. Required. :paramtype value: str @@ -463,14 +465,14 @@ class RuleCondition(_serialization.Model): } } - def __init__(self, *, data_source: Optional["_models.RuleDataSource"] = None, **kwargs): + def __init__(self, *, data_source: Optional["_models.RuleDataSource"] = None, **kwargs: Any) -> None: """ :keyword data_source: the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource. :paramtype data_source: ~$(python-base-namespace).v2015_07_01.models.RuleDataSource """ super().__init__(**kwargs) - self.odata_type = None # type: Optional[str] + self.odata_type: Optional[str] = None self.data_source = data_source @@ -514,8 +516,8 @@ def __init__( failed_location_count: int, data_source: Optional["_models.RuleDataSource"] = None, window_size: Optional[datetime.timedelta] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword data_source: the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource. @@ -529,7 +531,7 @@ def __init__( :paramtype failed_location_count: int """ super().__init__(data_source=data_source, **kwargs) - self.odata_type = "Microsoft.Azure.Management.Insights.Models.LocationThresholdRuleCondition" # type: str + self.odata_type: str = "Microsoft.Azure.Management.Insights.Models.LocationThresholdRuleCondition" self.window_size = window_size self.failed_location_count = failed_location_count @@ -565,8 +567,8 @@ def __init__( enabled: bool, category: Optional[str] = None, retention_policy: Optional["_models.RetentionPolicy"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword category: Name of a Diagnostic Log category for a resource type this setting is applied to. To obtain the list of Diagnostic Log categories for a resource, first perform a GET @@ -606,8 +608,8 @@ def __init__( name: Optional[str] = None, display_name: Optional[str] = None, blob_duration: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: Name of log specification. :paramtype name: str @@ -648,8 +650,8 @@ def __init__( operator: Optional[Union[str, "_models.ConditionOperator"]] = None, threshold: Optional[float] = None, window_size: Optional[datetime.timedelta] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword operator: the condition operator. Known values are: "GreaterThan", "GreaterThanOrEqual", "LessThan", and "LessThanOrEqual". @@ -702,8 +704,8 @@ def __init__( *, data_source: Optional["_models.RuleDataSource"] = None, aggregation: Optional["_models.ManagementEventAggregationCondition"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword data_source: the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource. @@ -715,12 +717,13 @@ def __init__( ~$(python-base-namespace).v2015_07_01.models.ManagementEventAggregationCondition """ super().__init__(data_source=data_source, **kwargs) - self.odata_type = "Microsoft.Azure.Management.Insights.Models.ManagementEventRuleCondition" # type: str + self.odata_type: str = "Microsoft.Azure.Management.Insights.Models.ManagementEventRuleCondition" self.aggregation = aggregation class MetricAvailability(_serialization.Model): - """Metric availability specifies the time grain (aggregation interval or frequency) and the retention period for that time grain. + """Metric availability specifies the time grain (aggregation interval or frequency) and the + retention period for that time grain. :ivar time_grain: the time grain specifies the aggregation interval for the metric. Expressed as a duration 'PT1M', 'P1D', etc. @@ -744,8 +747,8 @@ def __init__( time_grain: Optional[datetime.timedelta] = None, retention: Optional[datetime.timedelta] = None, location: Optional["_models.MetricAvailabilityLocation"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword time_grain: the time grain specifies the aggregation interval for the metric. Expressed as a duration 'PT1M', 'P1D', etc. @@ -785,8 +788,8 @@ def __init__( table_endpoint: Optional[str] = None, table_info: Optional[List["_models.TableInfoEntry"]] = None, partition_key: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword table_endpoint: The url for the storage account. :paramtype table_endpoint: str @@ -865,8 +868,8 @@ def __init__( supported_aggregation_types: Optional[List[Union[str, "_models.AggregationType"]]] = None, metric_availabilities: Optional[List["_models.MetricAvailability"]] = None, id: Optional[str] = None, # pylint: disable=redefined-builtin - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword resource_id: The resource identifier of the resource that emitted the metric. :paramtype resource_id: str @@ -938,8 +941,8 @@ def __init__( *, value: List["_models.MetricDefinition"], id: Optional[str] = None, # pylint: disable=redefined-builtin - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword id: Resource Id for these metric definitions. :paramtype id: str @@ -981,8 +984,8 @@ def __init__( time_grain: datetime.timedelta, enabled: bool, retention_policy: Optional["_models.RetentionPolicy"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword time_grain: the timegrain of the metric in ISO8601 format. Required. :paramtype time_grain: ~datetime.timedelta @@ -1062,8 +1065,8 @@ def __init__( dimensions: Optional[List["_models.DimensionProperties"]] = None, fill_gap_with_zero: Optional[bool] = None, internal_metric_name: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: The name of the metric. :paramtype name: str @@ -1138,8 +1141,8 @@ def __init__( is_data_action: Optional[bool] = None, display: Optional["_models.OperationDisplay"] = None, service_specification: Optional["_models.ServiceSpecification"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: Operation name: {provider}/{resource}/{operation}. :paramtype name: str @@ -1189,8 +1192,8 @@ def __init__( resource: Optional[str] = None, operation: Optional[str] = None, description: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword publisher: The publisher of this operation. :paramtype publisher: str @@ -1212,7 +1215,8 @@ def __init__( class OperationListResult(_serialization.Model): - """Result of the request to list Microsoft.Insights operations. It contains a list of operations and a URL link to get the next set of results. + """Result of the request to list Microsoft.Insights operations. It contains a list of operations + and a URL link to get the next set of results. :ivar value: List of operations supported by the Microsoft.Insights provider. :vartype value: list[~$(python-base-namespace).v2015_07_01.models.Operation] @@ -1225,7 +1229,9 @@ class OperationListResult(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs): + def __init__( + self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword value: List of operations supported by the Microsoft.Insights provider. :paramtype value: list[~$(python-base-namespace).v2015_07_01.models.Operation] @@ -1259,7 +1265,7 @@ class RetentionPolicy(_serialization.Model): "days": {"key": "days", "type": "int"}, } - def __init__(self, *, enabled: bool, days: int, **kwargs): + def __init__(self, *, enabled: bool, days: int, **kwargs: Any) -> None: """ :keyword enabled: a value indicating whether the retention policy is enabled. Required. :paramtype enabled: bool @@ -1273,7 +1279,8 @@ def __init__(self, *, enabled: bool, days: int, **kwargs): class RuleAction(_serialization.Model): - """The action that is performed when the alert rule becomes active, and when an alert condition is resolved. + """The action that is performed when the alert rule becomes active, and when an alert condition is + resolved. You probably want to use the sub-classes and not this class directly. Known sub-classes are: RuleEmailAction, RuleWebhookAction @@ -1300,10 +1307,10 @@ class RuleAction(_serialization.Model): } } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.odata_type = None # type: Optional[str] + self.odata_type: Optional[str] = None class RuleDataSource(_serialization.Model): @@ -1355,8 +1362,8 @@ def __init__( legacy_resource_id: Optional[str] = None, resource_location: Optional[str] = None, metric_namespace: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : this property cannot be updated for an existing rule. @@ -1370,7 +1377,7 @@ def __init__( :paramtype metric_namespace: str """ super().__init__(**kwargs) - self.odata_type = None # type: Optional[str] + self.odata_type: Optional[str] = None self.resource_uri = resource_uri self.legacy_resource_id = legacy_resource_id self.resource_location = resource_location @@ -1378,7 +1385,8 @@ def __init__( class RuleEmailAction(RuleAction): - """Specifies the action to send email when the rule condition is evaluated. The discriminator is always RuleEmailAction in this case. + """Specifies the action to send email when the rule condition is evaluated. The discriminator is + always RuleEmailAction in this case. All required parameters must be populated in order to send to Azure. @@ -1404,8 +1412,8 @@ class RuleEmailAction(RuleAction): } def __init__( - self, *, send_to_service_owners: Optional[bool] = None, custom_emails: Optional[List[str]] = None, **kwargs - ): + self, *, send_to_service_owners: Optional[bool] = None, custom_emails: Optional[List[str]] = None, **kwargs: Any + ) -> None: """ :keyword send_to_service_owners: Whether the administrators (service and co-administrators) of the service should be notified when the alert is activated. @@ -1415,7 +1423,7 @@ def __init__( :paramtype custom_emails: list[str] """ super().__init__(**kwargs) - self.odata_type = "Microsoft.Azure.Management.Insights.Models.RuleEmailAction" # type: str + self.odata_type: str = "Microsoft.Azure.Management.Insights.Models.RuleEmailAction" self.send_to_service_owners = send_to_service_owners self.custom_emails = custom_emails @@ -1431,7 +1439,7 @@ class RuleManagementEventClaimsDataSource(_serialization.Model): "email_address": {"key": "emailAddress", "type": "str"}, } - def __init__(self, *, email_address: Optional[str] = None, **kwargs): + def __init__(self, *, email_address: Optional[str] = None, **kwargs: Any) -> None: """ :keyword email_address: the email address. :paramtype email_address: str @@ -1441,7 +1449,8 @@ def __init__(self, *, email_address: Optional[str] = None, **kwargs): class RuleManagementEventDataSource(RuleDataSource): # pylint: disable=too-many-instance-attributes - """A rule management event data source. The discriminator fields is always RuleManagementEventDataSource in this case. + """A rule management event data source. The discriminator fields is always + RuleManagementEventDataSource in this case. All required parameters must be populated in order to send to Azure. @@ -1518,8 +1527,8 @@ def __init__( status: Optional[str] = None, sub_status: Optional[str] = None, claims: Optional["_models.RuleManagementEventClaimsDataSource"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : this property cannot be updated for an existing rule. @@ -1560,7 +1569,7 @@ def __init__( metric_namespace=metric_namespace, **kwargs ) - self.odata_type = "Microsoft.Azure.Management.Insights.Models.RuleManagementEventDataSource" # type: str + self.odata_type: str = "Microsoft.Azure.Management.Insights.Models.RuleManagementEventDataSource" self.event_name = event_name self.event_source = event_source self.level = level @@ -1615,8 +1624,8 @@ def __init__( resource_location: Optional[str] = None, metric_namespace: Optional[str] = None, metric_name: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : this property cannot be updated for an existing rule. @@ -1638,12 +1647,13 @@ def __init__( metric_namespace=metric_namespace, **kwargs ) - self.odata_type = "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource" # type: str + self.odata_type: str = "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource" self.metric_name = metric_name class RuleWebhookAction(RuleAction): - """Specifies the action to post to service when the rule condition is evaluated. The discriminator is always RuleWebhookAction in this case. + """Specifies the action to post to service when the rule condition is evaluated. The discriminator + is always RuleWebhookAction in this case. All required parameters must be populated in order to send to Azure. @@ -1668,7 +1678,9 @@ class RuleWebhookAction(RuleAction): "properties": {"key": "properties", "type": "{str}"}, } - def __init__(self, *, service_uri: Optional[str] = None, properties: Optional[Dict[str, str]] = None, **kwargs): + def __init__( + self, *, service_uri: Optional[str] = None, properties: Optional[Dict[str, str]] = None, **kwargs: Any + ) -> None: """ :keyword service_uri: the service uri to Post the notification when the alert activates or resolves. @@ -1678,7 +1690,7 @@ def __init__(self, *, service_uri: Optional[str] = None, properties: Optional[Di :paramtype properties: dict[str, str] """ super().__init__(**kwargs) - self.odata_type = "Microsoft.Azure.Management.Insights.Models.RuleWebhookAction" # type: str + self.odata_type: str = "Microsoft.Azure.Management.Insights.Models.RuleWebhookAction" self.service_uri = service_uri self.properties = properties @@ -1747,8 +1759,8 @@ def __init__( metrics: Optional[List["_models.MetricSettings"]] = None, logs: Optional[List["_models.LogSettings"]] = None, workspace_id: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword location: Resource location. Required. :paramtype location: str @@ -1804,8 +1816,8 @@ def __init__( log_specifications: Optional[List["_models.LogSpecification"]] = None, metric_specifications: Optional[List["_models.MetricSpecification"]] = None, legacy_metric_specifications: Optional[JSON] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword log_specifications: Log specifications of operation. :paramtype log_specifications: @@ -1854,8 +1866,8 @@ def __init__( end_time: Optional[datetime.datetime] = None, sas_token: Optional[str] = None, sas_token_expiration_time: Optional[datetime.datetime] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword table_name: Name of a table with metric data for this resource. :paramtype table_name: str @@ -1928,8 +1940,8 @@ def __init__( data_source: Optional["_models.RuleDataSource"] = None, window_size: Optional[datetime.timedelta] = None, time_aggregation: Optional[Union[str, "_models.TimeAggregationOperator"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword data_source: the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource. @@ -1950,7 +1962,7 @@ def __init__( ~$(python-base-namespace).v2015_07_01.models.TimeAggregationOperator """ super().__init__(data_source=data_source, **kwargs) - self.odata_type = "Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition" # type: str + self.odata_type: str = "Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition" self.operator = operator self.threshold = threshold self.window_size = window_size diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/__init__.py index 5737890365bd..acff6da37ac2 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/__init__.py @@ -12,7 +12,7 @@ from ._operations import Operations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_alert_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_alert_rules_operations.py index 0cd1354eae8a..659e1e336d21 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_alert_rules_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_alert_rules_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -28,6 +29,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -41,8 +46,8 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2014-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -58,7 +63,7 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -75,7 +80,7 @@ def build_delete_request(resource_group_name: str, rule_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str + api_version: Literal["2014-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -91,7 +96,7 @@ def build_delete_request(resource_group_name: str, rule_name: str, subscription_ "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -106,7 +111,7 @@ def build_get_request(resource_group_name: str, rule_name: str, subscription_id: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str + api_version: Literal["2014-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -122,7 +127,7 @@ def build_get_request(resource_group_name: str, rule_name: str, subscription_id: "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -137,8 +142,8 @@ def build_update_request(resource_group_name: str, rule_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2014-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -154,7 +159,7 @@ def build_update_request(resource_group_name: str, rule_name: str, subscription_ "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -171,7 +176,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str + api_version: Literal["2014-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -186,7 +191,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -201,7 +206,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str + api_version: Literal["2014-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -210,7 +215,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -307,8 +312,8 @@ def create_or_update( :type resource_group_name: str :param rule_name: The name of the rule. Required. :type rule_name: str - :param parameters: The parameters of the rule to create or update. Is either a model type or a - IO type. Required. + :param parameters: The parameters of the rule to create or update. Is either a + AlertRuleResource type or a IO type. Required. :type parameters: ~$(python-base-namespace).v2015_07_01.models.AlertRuleResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -329,9 +334,9 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResource] + api_version: Literal["2014-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AlertRuleResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -354,9 +359,9 @@ def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -374,11 +379,13 @@ def create_or_update( deserialized = self._deserialize("AlertRuleResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -407,8 +414,8 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2014-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -420,9 +427,9 @@ def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -436,7 +443,9 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}" + } @distributed_trace def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _models.AlertRuleResource: @@ -463,8 +472,8 @@ def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _model _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResource] + api_version: Literal["2014-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) + cls: ClsType[_models.AlertRuleResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -476,9 +485,9 @@ def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _model params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -496,7 +505,9 @@ def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _model return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}" + } @overload def update( @@ -572,8 +583,8 @@ def update( :type resource_group_name: str :param rule_name: The name of the rule. Required. :type rule_name: str - :param alert_rules_resource: Parameters supplied to the operation. Is either a model type or a - IO type. Required. + :param alert_rules_resource: Parameters supplied to the operation. Is either a + AlertRuleResourcePatch type or a IO type. Required. :type alert_rules_resource: ~$(python-base-namespace).v2015_07_01.models.AlertRuleResourcePatch or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -595,9 +606,9 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResource] + api_version: Literal["2014-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AlertRuleResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -620,9 +631,9 @@ def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -640,11 +651,13 @@ def update( deserialized = self._deserialize("AlertRuleResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}" + } @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.AlertRuleResource"]: @@ -662,8 +675,8 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResourceCollection] + api_version: Literal["2014-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) + cls: ClsType[_models.AlertRuleResourceCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -685,12 +698,12 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -698,13 +711,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("AlertRuleResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -718,7 +731,9 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules" + } @distributed_trace def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.AlertRuleResource"]: @@ -733,8 +748,8 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.AlertRuleReso _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResourceCollection] + api_version: Literal["2014-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2014-04-01")) + cls: ClsType[_models.AlertRuleResourceCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -755,12 +770,12 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -768,13 +783,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("AlertRuleResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -788,4 +803,4 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/alertrules"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/alertrules"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_metric_definitions_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_metric_definitions_operations.py index f911fc56a852..8c33a0ef8021 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_metric_definitions_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_metric_definitions_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar from azure.core.exceptions import ( @@ -28,6 +29,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -39,7 +44,7 @@ def build_list_request(resource_uri: str, *, filter: Optional[str] = None, **kwa _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) # type: str + api_version: Literal["2015-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -48,7 +53,7 @@ def build_list_request(resource_uri: str, *, filter: Optional[str] = None, **kwa "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -104,8 +109,8 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricDefinitionCollection] + api_version: Literal["2015-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) + cls: ClsType[_models.MetricDefinitionCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -127,12 +132,12 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: request = HttpRequest("GET", next_link) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -140,13 +145,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("MetricDefinitionCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -160,4 +165,4 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/metricDefinitions"} # type: ignore + list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/metricDefinitions"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_operations.py index a00df2b36140..4f0545b94260 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -27,6 +28,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -38,7 +43,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 = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) # type: str + api_version: Literal["2015-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -92,8 +97,8 @@ def list(self, **kwargs: Any) -> _models.OperationListResult: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] + api_version: Literal["2015-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) request = build_list_request( api_version=api_version, @@ -102,9 +107,9 @@ def list(self, **kwargs: Any) -> _models.OperationListResult: params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -122,4 +127,4 @@ def list(self, **kwargs: Any) -> _models.OperationListResult: return deserialized - list.metadata = {"url": "/providers/Microsoft.Insights/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Insights/operations"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_service_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_service_diagnostic_settings_operations.py index 9eddb3eddb44..c560bd6578cd 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_service_diagnostic_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_service_diagnostic_settings_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -27,6 +28,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -38,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 = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) # type: str + api_version: Literal["2015-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -47,7 +52,7 @@ def build_get_request(resource_uri: str, **kwargs: Any) -> HttpRequest: "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -62,8 +67,8 @@ 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 = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2015-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -72,7 +77,7 @@ def build_create_or_update_request(resource_uri: str, **kwargs: Any) -> HttpRequ "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -126,8 +131,8 @@ def get(self, resource_uri: str, **kwargs: Any) -> _models.ServiceDiagnosticSett _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceDiagnosticSettingsResource] + api_version: Literal["2015-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) + cls: ClsType[_models.ServiceDiagnosticSettingsResource] = kwargs.pop("cls", None) request = build_get_request( resource_uri=resource_uri, @@ -137,9 +142,9 @@ def get(self, resource_uri: str, **kwargs: Any) -> _models.ServiceDiagnosticSett params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -157,7 +162,7 @@ def get(self, resource_uri: str, **kwargs: Any) -> _models.ServiceDiagnosticSett return deserialized - get.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service"} # type: ignore + get.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service"} @overload def create_or_update( @@ -211,8 +216,8 @@ def create_or_update( :param resource_uri: The identifier of the resource. Required. :type resource_uri: str - :param parameters: Parameters supplied to the operation. Is either a model type or a IO type. - Required. + :param parameters: Parameters supplied to the operation. Is either a + ServiceDiagnosticSettingsResource type or a IO type. Required. :type parameters: ~$(python-base-namespace).v2015_07_01.models.ServiceDiagnosticSettingsResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -234,9 +239,9 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceDiagnosticSettingsResource] + api_version: Literal["2015-07-01"] = kwargs.pop("api_version", _params.pop("api-version", "2015-07-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ServiceDiagnosticSettingsResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -257,9 +262,9 @@ def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -276,4 +281,4 @@ def create_or_update( return deserialized - create_or_update.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service"} # type: ignore + create_or_update.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/__init__.py index 8ba4823444a9..2c7733bfd566 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/__init__.py @@ -13,12 +13,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["MonitorManagementClient"] +__all__ = [ + "MonitorManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_configuration.py index 4e506b40a11a..a0bc5d9fd0fe 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -36,7 +42,7 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2016-03-01") # type: str + api_version: Literal["2016-03-01"] = kwargs.pop("api_version", "2016-03-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -50,10 +56,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, **kwargs # type: Any - ): - # type: (...) -> None + def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_metadata.json index da26c934e00d..4a901aa6bb4a 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_metadata.json @@ -19,13 +19,15 @@ "signature": "credential: \"TokenCredential\",", "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true + "required": true, + "method_location": "positional" }, "subscription_id": { "signature": "subscription_id: str,", "description": "The ID of the target subscription. Required.", "docstring_type": "str", - "required": true + "required": true, + "method_location": "positional" } }, "async": { @@ -48,22 +50,25 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "signature": "api_version: Optional[str]=None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } }, "async": { @@ -71,19 +76,22 @@ "signature": "api_version: Optional[str] = None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { "signature": "profile: KnownProfiles = KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } } } @@ -102,4 +110,4 @@ "log_profiles": "LogProfilesOperations", "metric_definitions": "MetricDefinitionsOperations" } -} \ No newline at end of file +} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_monitor_management_client.py index 9532ba73144a..f65c796fe1fd 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_monitor_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from . import models +from . import models as _models from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ( @@ -63,7 +63,7 @@ def __init__( ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -98,15 +98,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> MonitorManagementClient + def __enter__(self) -> "MonitorManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_vendor.py index 9aad73fc743e..bd0df84f5319 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_vendor.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_vendor.py @@ -5,6 +5,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import List, cast + from azure.core.pipeline.transport import HttpRequest @@ -22,6 +24,7 @@ def _format_url_section(template, **kwargs): try: return template.format(**kwargs) except KeyError as key: - formatted_components = template.split("/") + # Need the cast, as for some reasons "split" is typed as list[str | Any] + formatted_components = cast(List[str], template.split("/")) components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_version.py index ce9ac7ae37b3..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/__init__.py index 8638dc69d869..2c151bb41c19 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/__init__.py @@ -10,12 +10,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["MonitorManagementClient"] +__all__ = [ + "MonitorManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/_configuration.py index 5c68c583285c..41f10ab23424 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -36,7 +42,7 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2016-03-01") # type: str + api_version: Literal["2016-03-01"] = kwargs.pop("api_version", "2016-03-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/_monitor_management_client.py index 93f3d940077a..58335737c8e7 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/_monitor_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from .. import models +from .. import models as _models from ..._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ( @@ -64,7 +64,7 @@ def __init__( ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -106,5 +106,5 @@ async def __aenter__(self) -> "MonitorManagementClient": await self._client.__aenter__() return self - async def __aexit__(self, *exc_details) -> None: + async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/__init__.py index ba29eb66c1f6..185356695cfa 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/__init__.py @@ -12,7 +12,7 @@ from ._metric_definitions_operations import MetricDefinitionsOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_alert_rule_incidents_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_alert_rule_incidents_operations.py index faf455bee087..dac871aab1ee 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_alert_rule_incidents_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_alert_rule_incidents_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -30,6 +31,10 @@ from ..._vendor import _convert_request from ...operations._alert_rule_incidents_operations import build_get_request, build_list_by_alert_rule_request +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -82,8 +87,8 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.Incident] + api_version: Literal["2016-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) + cls: ClsType[_models.Incident] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -96,9 +101,9 @@ async def get( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -116,7 +121,9 @@ async def get( return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}/incidents/{incidentName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}/incidents/{incidentName}" + } @distributed_trace def list_by_alert_rule( @@ -138,8 +145,8 @@ def list_by_alert_rule( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.IncidentListResult] + api_version: Literal["2016-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) + cls: ClsType[_models.IncidentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -162,16 +169,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -179,13 +193,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("IncidentListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -198,4 +212,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_alert_rule.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}/incidents"} # type: ignore + list_by_alert_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}/incidents" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_alert_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_alert_rules_operations.py index 6f8ce6cfcdcb..93ab0d506b0f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_alert_rules_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_alert_rules_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -37,6 +38,10 @@ build_update_request, ) +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -127,8 +132,8 @@ async def create_or_update( :type resource_group_name: str :param rule_name: The name of the rule. Required. :type rule_name: str - :param parameters: The parameters of the rule to create or update. Is either a model type or a - IO type. Required. + :param parameters: The parameters of the rule to create or update. Is either a + AlertRuleResource type or a IO type. Required. :type parameters: ~$(python-base-namespace).v2016_03_01.models.AlertRuleResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -149,9 +154,9 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResource] + api_version: Literal["2016-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AlertRuleResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -174,9 +179,9 @@ async def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -194,11 +199,13 @@ async def create_or_update( deserialized = self._deserialize("AlertRuleResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -227,8 +234,8 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2016-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -240,9 +247,9 @@ async def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -256,7 +263,9 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}" + } @distributed_trace_async async def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _models.AlertRuleResource: @@ -283,8 +292,8 @@ async def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResource] + api_version: Literal["2016-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) + cls: ClsType[_models.AlertRuleResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -296,9 +305,9 @@ async def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -316,7 +325,9 @@ async def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}" + } @overload async def update( @@ -392,8 +403,8 @@ async def update( :type resource_group_name: str :param rule_name: The name of the rule. Required. :type rule_name: str - :param alert_rules_resource: Parameters supplied to the operation. Is either a model type or a - IO type. Required. + :param alert_rules_resource: Parameters supplied to the operation. Is either a + AlertRuleResourcePatch type or a IO type. Required. :type alert_rules_resource: ~$(python-base-namespace).v2016_03_01.models.AlertRuleResourcePatch or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -415,9 +426,9 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResource] + api_version: Literal["2016-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AlertRuleResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -440,9 +451,9 @@ async def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -460,11 +471,13 @@ async def update( deserialized = self._deserialize("AlertRuleResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}" + } @distributed_trace def list_by_resource_group( @@ -484,8 +497,8 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResourceCollection] + api_version: Literal["2016-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) + cls: ClsType[_models.AlertRuleResourceCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -507,16 +520,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -524,13 +544,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("AlertRuleResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -544,7 +564,9 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules" + } @distributed_trace def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.AlertRuleResource"]: @@ -559,8 +581,8 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.AlertRul _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResourceCollection] + api_version: Literal["2016-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) + cls: ClsType[_models.AlertRuleResourceCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -581,16 +603,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -598,13 +627,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("AlertRuleResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -618,4 +647,4 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/alertrules"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/alertrules"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_log_profiles_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_log_profiles_operations.py index 26e4d6ed1e10..dc5f5521affa 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_log_profiles_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_log_profiles_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -36,6 +37,10 @@ build_update_request, ) +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -83,8 +88,8 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2016-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( log_profile_name=log_profile_name, @@ -95,9 +100,9 @@ async def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -110,7 +115,9 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}" + } @distributed_trace_async async def get(self, log_profile_name: str, **kwargs: Any) -> _models.LogProfileResource: @@ -134,8 +141,8 @@ async def get(self, log_profile_name: str, **kwargs: Any) -> _models.LogProfileR _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.LogProfileResource] + api_version: Literal["2016-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) + cls: ClsType[_models.LogProfileResource] = kwargs.pop("cls", None) request = build_get_request( log_profile_name=log_profile_name, @@ -146,9 +153,9 @@ async def get(self, log_profile_name: str, **kwargs: Any) -> _models.LogProfileR params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -166,7 +173,7 @@ async def get(self, log_profile_name: str, **kwargs: Any) -> _models.LogProfileR return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}"} @overload async def create_or_update( @@ -219,8 +226,8 @@ async def create_or_update( :param log_profile_name: The name of the log profile. Required. :type log_profile_name: str - :param parameters: Parameters supplied to the operation. Is either a model type or a IO type. - Required. + :param parameters: Parameters supplied to the operation. Is either a LogProfileResource type or + a IO type. Required. :type parameters: ~$(python-base-namespace).v2016_03_01.models.LogProfileResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -241,9 +248,9 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.LogProfileResource] + api_version: Literal["2016-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LogProfileResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -265,9 +272,9 @@ async def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -284,7 +291,9 @@ async def create_or_update( return deserialized - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}" + } @overload async def update( @@ -338,8 +347,8 @@ async def update( :param log_profile_name: The name of the log profile. Required. :type log_profile_name: str - :param log_profiles_resource: Parameters supplied to the operation. Is either a model type or a - IO type. Required. + :param log_profiles_resource: Parameters supplied to the operation. Is either a + LogProfileResourcePatch type or a IO type. Required. :type log_profiles_resource: ~$(python-base-namespace).v2016_03_01.models.LogProfileResourcePatch or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -361,9 +370,9 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.LogProfileResource] + api_version: Literal["2016-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LogProfileResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -385,9 +394,9 @@ async def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -405,7 +414,9 @@ async def update( return deserialized - update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}" + } @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.LogProfileResource"]: @@ -420,8 +431,8 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.LogProfileResource"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.LogProfileCollection] + api_version: Literal["2016-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) + cls: ClsType[_models.LogProfileCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -442,16 +453,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -459,13 +477,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("LogProfileCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -478,4 +496,4 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_metric_definitions_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_metric_definitions_operations.py index 3db3c7b07ac3..e23f71fae792 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_metric_definitions_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_metric_definitions_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -29,6 +30,10 @@ from ..._vendor import _convert_request from ...operations._metric_definitions_operations import build_list_request +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -76,8 +81,8 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricDefinitionCollection] + api_version: Literal["2016-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) + cls: ClsType[_models.MetricDefinitionCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -99,16 +104,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -116,13 +128,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("MetricDefinitionCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -136,4 +148,4 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/metricDefinitions"} # type: ignore + list.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/metricDefinitions"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/__init__.py index a9a18ee60bc6..07226e45344b 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/__init__.py @@ -39,7 +39,7 @@ from ._monitor_management_client_enums import TimeAggregationOperator from ._monitor_management_client_enums import Unit from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/_models_py3.py index d930762bdee2..f8da2cbaea2e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/_models_py3.py @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, TYPE_CHECKING, Union +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union from ... import _serialization @@ -51,7 +51,7 @@ class Resource(_serialization.Model): "tags": {"key": "tags", "type": "{str}"}, } - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: """ :keyword location: Resource location. Required. :paramtype location: str @@ -142,8 +142,8 @@ def __init__( provisioning_state: Optional[str] = None, action: Optional["_models.RuleAction"] = None, actions: Optional[List["_models.RuleAction"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword location: Resource location. Required. :paramtype location: str @@ -189,7 +189,7 @@ class AlertRuleResourceCollection(_serialization.Model): "value": {"key": "value", "type": "[AlertRuleResource]"}, } - def __init__(self, *, value: Optional[List["_models.AlertRuleResource"]] = None, **kwargs): + def __init__(self, *, value: Optional[List["_models.AlertRuleResource"]] = None, **kwargs: Any) -> None: """ :keyword value: the values for the alert rule resources. :paramtype value: list[~$(python-base-namespace).v2016_03_01.models.AlertRuleResource] @@ -252,8 +252,8 @@ def __init__( condition: Optional["_models.RuleCondition"] = None, action: Optional["_models.RuleAction"] = None, actions: Optional[List["_models.RuleAction"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword tags: Resource tags. :paramtype tags: dict[str, str] @@ -301,7 +301,7 @@ class ErrorResponse(_serialization.Model): "message": {"key": "message", "type": "str"}, } - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: """ :keyword code: Error code. :paramtype code: str @@ -347,7 +347,7 @@ class Incident(_serialization.Model): "resolved_time": {"key": "resolvedTime", "type": "iso-8601"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.name = None @@ -368,7 +368,7 @@ class IncidentListResult(_serialization.Model): "value": {"key": "value", "type": "[Incident]"}, } - def __init__(self, *, value: Optional[List["_models.Incident"]] = None, **kwargs): + def __init__(self, *, value: Optional[List["_models.Incident"]] = None, **kwargs: Any) -> None: """ :keyword value: the incident collection. :paramtype value: list[~$(python-base-namespace).v2016_03_01.models.Incident] @@ -397,7 +397,7 @@ class LocalizableString(_serialization.Model): "localized_value": {"key": "localizedValue", "type": "str"}, } - def __init__(self, *, value: str, localized_value: Optional[str] = None, **kwargs): + def __init__(self, *, value: str, localized_value: Optional[str] = None, **kwargs: Any) -> None: """ :keyword value: the invariant value. Required. :paramtype value: str @@ -444,14 +444,14 @@ class RuleCondition(_serialization.Model): } } - def __init__(self, *, data_source: Optional["_models.RuleDataSource"] = None, **kwargs): + def __init__(self, *, data_source: Optional["_models.RuleDataSource"] = None, **kwargs: Any) -> None: """ :keyword data_source: the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource. :paramtype data_source: ~$(python-base-namespace).v2016_03_01.models.RuleDataSource """ super().__init__(**kwargs) - self.odata_type = None # type: Optional[str] + self.odata_type: Optional[str] = None self.data_source = data_source @@ -495,8 +495,8 @@ def __init__( failed_location_count: int, data_source: Optional["_models.RuleDataSource"] = None, window_size: Optional[datetime.timedelta] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword data_source: the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource. @@ -510,7 +510,7 @@ def __init__( :paramtype failed_location_count: int """ super().__init__(data_source=data_source, **kwargs) - self.odata_type = "Microsoft.Azure.Management.Insights.Models.LocationThresholdRuleCondition" # type: str + self.odata_type: str = "Microsoft.Azure.Management.Insights.Models.LocationThresholdRuleCondition" self.window_size = window_size self.failed_location_count = failed_location_count @@ -532,7 +532,7 @@ class LogProfileCollection(_serialization.Model): "value": {"key": "value", "type": "[LogProfileResource]"}, } - def __init__(self, *, value: List["_models.LogProfileResource"], **kwargs): + def __init__(self, *, value: List["_models.LogProfileResource"], **kwargs: Any) -> None: """ :keyword value: the values of the log profiles. Required. :paramtype value: list[~$(python-base-namespace).v2016_03_01.models.LogProfileResource] @@ -608,8 +608,8 @@ def __init__( tags: Optional[Dict[str, str]] = None, storage_account_id: Optional[str] = None, service_bus_rule_id: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword location: Resource location. Required. :paramtype location: str @@ -679,8 +679,8 @@ def __init__( locations: Optional[List[str]] = None, categories: Optional[List[str]] = None, retention_policy: Optional["_models.RetentionPolicy"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword tags: Resource tags. :paramtype tags: dict[str, str] @@ -735,8 +735,8 @@ def __init__( operator: Optional[Union[str, "_models.ConditionOperator"]] = None, threshold: Optional[float] = None, window_size: Optional[datetime.timedelta] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword operator: the condition operator. Known values are: "GreaterThan", "GreaterThanOrEqual", "LessThan", and "LessThanOrEqual". @@ -789,8 +789,8 @@ def __init__( *, data_source: Optional["_models.RuleDataSource"] = None, aggregation: Optional["_models.ManagementEventAggregationCondition"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword data_source: the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource. @@ -802,12 +802,13 @@ def __init__( ~$(python-base-namespace).v2016_03_01.models.ManagementEventAggregationCondition """ super().__init__(data_source=data_source, **kwargs) - self.odata_type = "Microsoft.Azure.Management.Insights.Models.ManagementEventRuleCondition" # type: str + self.odata_type: str = "Microsoft.Azure.Management.Insights.Models.ManagementEventRuleCondition" self.aggregation = aggregation class MetricAvailability(_serialization.Model): - """Metric availability specifies the time grain (aggregation interval or frequency) and the retention period for that time grain. + """Metric availability specifies the time grain (aggregation interval or frequency) and the + retention period for that time grain. :ivar time_grain: the time grain specifies the aggregation interval for the metric. Expressed as a duration 'PT1M', 'P1D', etc. @@ -827,8 +828,8 @@ def __init__( *, time_grain: Optional[datetime.timedelta] = None, retention: Optional[datetime.timedelta] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword time_grain: the time grain specifies the aggregation interval for the metric. Expressed as a duration 'PT1M', 'P1D', etc. @@ -884,8 +885,8 @@ def __init__( primary_aggregation_type: Optional[Union[str, "_models.AggregationType"]] = None, metric_availabilities: Optional[List["_models.MetricAvailability"]] = None, id: Optional[str] = None, # pylint: disable=redefined-builtin - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword resource_id: the resource identifier of the resource that emitted the metric. :paramtype resource_id: str @@ -933,7 +934,7 @@ class MetricDefinitionCollection(_serialization.Model): "value": {"key": "value", "type": "[MetricDefinition]"}, } - def __init__(self, *, value: List["_models.MetricDefinition"], **kwargs): + def __init__(self, *, value: List["_models.MetricDefinition"], **kwargs: Any) -> None: """ :keyword value: the values for the metric definitions. Required. :paramtype value: list[~$(python-base-namespace).v2016_03_01.models.MetricDefinition] @@ -964,7 +965,7 @@ class RetentionPolicy(_serialization.Model): "days": {"key": "days", "type": "int"}, } - def __init__(self, *, enabled: bool, days: int, **kwargs): + def __init__(self, *, enabled: bool, days: int, **kwargs: Any) -> None: """ :keyword enabled: a value indicating whether the retention policy is enabled. Required. :paramtype enabled: bool @@ -978,7 +979,8 @@ def __init__(self, *, enabled: bool, days: int, **kwargs): class RuleAction(_serialization.Model): - """The action that is performed when the alert rule becomes active, and when an alert condition is resolved. + """The action that is performed when the alert rule becomes active, and when an alert condition is + resolved. You probably want to use the sub-classes and not this class directly. Known sub-classes are: RuleEmailAction, RuleWebhookAction @@ -1005,10 +1007,10 @@ class RuleAction(_serialization.Model): } } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.odata_type = None # type: Optional[str] + self.odata_type: Optional[str] = None class RuleDataSource(_serialization.Model): @@ -1060,8 +1062,8 @@ def __init__( legacy_resource_id: Optional[str] = None, resource_location: Optional[str] = None, metric_namespace: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : this property cannot be updated for an existing rule. @@ -1075,7 +1077,7 @@ def __init__( :paramtype metric_namespace: str """ super().__init__(**kwargs) - self.odata_type = None # type: Optional[str] + self.odata_type: Optional[str] = None self.resource_uri = resource_uri self.legacy_resource_id = legacy_resource_id self.resource_location = resource_location @@ -1083,7 +1085,8 @@ def __init__( class RuleEmailAction(RuleAction): - """Specifies the action to send email when the rule condition is evaluated. The discriminator is always RuleEmailAction in this case. + """Specifies the action to send email when the rule condition is evaluated. The discriminator is + always RuleEmailAction in this case. All required parameters must be populated in order to send to Azure. @@ -1109,8 +1112,8 @@ class RuleEmailAction(RuleAction): } def __init__( - self, *, send_to_service_owners: Optional[bool] = None, custom_emails: Optional[List[str]] = None, **kwargs - ): + self, *, send_to_service_owners: Optional[bool] = None, custom_emails: Optional[List[str]] = None, **kwargs: Any + ) -> None: """ :keyword send_to_service_owners: Whether the administrators (service and co-administrators) of the service should be notified when the alert is activated. @@ -1120,7 +1123,7 @@ def __init__( :paramtype custom_emails: list[str] """ super().__init__(**kwargs) - self.odata_type = "Microsoft.Azure.Management.Insights.Models.RuleEmailAction" # type: str + self.odata_type: str = "Microsoft.Azure.Management.Insights.Models.RuleEmailAction" self.send_to_service_owners = send_to_service_owners self.custom_emails = custom_emails @@ -1136,7 +1139,7 @@ class RuleManagementEventClaimsDataSource(_serialization.Model): "email_address": {"key": "emailAddress", "type": "str"}, } - def __init__(self, *, email_address: Optional[str] = None, **kwargs): + def __init__(self, *, email_address: Optional[str] = None, **kwargs: Any) -> None: """ :keyword email_address: the email address. :paramtype email_address: str @@ -1146,7 +1149,8 @@ def __init__(self, *, email_address: Optional[str] = None, **kwargs): class RuleManagementEventDataSource(RuleDataSource): # pylint: disable=too-many-instance-attributes - """A rule management event data source. The discriminator fields is always RuleManagementEventDataSource in this case. + """A rule management event data source. The discriminator fields is always + RuleManagementEventDataSource in this case. All required parameters must be populated in order to send to Azure. @@ -1223,8 +1227,8 @@ def __init__( status: Optional[str] = None, sub_status: Optional[str] = None, claims: Optional["_models.RuleManagementEventClaimsDataSource"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : this property cannot be updated for an existing rule. @@ -1265,7 +1269,7 @@ def __init__( metric_namespace=metric_namespace, **kwargs ) - self.odata_type = "Microsoft.Azure.Management.Insights.Models.RuleManagementEventDataSource" # type: str + self.odata_type: str = "Microsoft.Azure.Management.Insights.Models.RuleManagementEventDataSource" self.event_name = event_name self.event_source = event_source self.level = level @@ -1320,8 +1324,8 @@ def __init__( resource_location: Optional[str] = None, metric_namespace: Optional[str] = None, metric_name: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : this property cannot be updated for an existing rule. @@ -1343,12 +1347,13 @@ def __init__( metric_namespace=metric_namespace, **kwargs ) - self.odata_type = "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource" # type: str + self.odata_type: str = "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource" self.metric_name = metric_name class RuleWebhookAction(RuleAction): - """Specifies the action to post to service when the rule condition is evaluated. The discriminator is always RuleWebhookAction in this case. + """Specifies the action to post to service when the rule condition is evaluated. The discriminator + is always RuleWebhookAction in this case. All required parameters must be populated in order to send to Azure. @@ -1373,7 +1378,9 @@ class RuleWebhookAction(RuleAction): "properties": {"key": "properties", "type": "{str}"}, } - def __init__(self, *, service_uri: Optional[str] = None, properties: Optional[Dict[str, str]] = None, **kwargs): + def __init__( + self, *, service_uri: Optional[str] = None, properties: Optional[Dict[str, str]] = None, **kwargs: Any + ) -> None: """ :keyword service_uri: the service uri to Post the notification when the alert activates or resolves. @@ -1383,7 +1390,7 @@ def __init__(self, *, service_uri: Optional[str] = None, properties: Optional[Di :paramtype properties: dict[str, str] """ super().__init__(**kwargs) - self.odata_type = "Microsoft.Azure.Management.Insights.Models.RuleWebhookAction" # type: str + self.odata_type: str = "Microsoft.Azure.Management.Insights.Models.RuleWebhookAction" self.service_uri = service_uri self.properties = properties @@ -1440,8 +1447,8 @@ def __init__( data_source: Optional["_models.RuleDataSource"] = None, window_size: Optional[datetime.timedelta] = None, time_aggregation: Optional[Union[str, "_models.TimeAggregationOperator"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword data_source: the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource. @@ -1462,7 +1469,7 @@ def __init__( ~$(python-base-namespace).v2016_03_01.models.TimeAggregationOperator """ super().__init__(data_source=data_source, **kwargs) - self.odata_type = "Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition" # type: str + self.odata_type: str = "Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition" self.operator = operator self.threshold = threshold self.window_size = window_size diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/__init__.py index ba29eb66c1f6..185356695cfa 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/__init__.py @@ -12,7 +12,7 @@ from ._metric_definitions_operations import MetricDefinitionsOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_alert_rule_incidents_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_alert_rule_incidents_operations.py index c309bebec06e..52c43377d488 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_alert_rule_incidents_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_alert_rule_incidents_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -42,7 +47,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str + api_version: Literal["2016-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -59,7 +64,7 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -76,7 +81,7 @@ def build_list_by_alert_rule_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str + api_version: Literal["2016-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -92,7 +97,7 @@ def build_list_by_alert_rule_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -149,8 +154,8 @@ def get(self, resource_group_name: str, rule_name: str, incident_name: str, **kw _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.Incident] + api_version: Literal["2016-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) + cls: ClsType[_models.Incident] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -163,9 +168,9 @@ def get(self, resource_group_name: str, rule_name: str, incident_name: str, **kw params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -183,7 +188,9 @@ def get(self, resource_group_name: str, rule_name: str, incident_name: str, **kw return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}/incidents/{incidentName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}/incidents/{incidentName}" + } @distributed_trace def list_by_alert_rule( @@ -204,8 +211,8 @@ def list_by_alert_rule( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.IncidentListResult] + api_version: Literal["2016-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) + cls: ClsType[_models.IncidentListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -228,16 +235,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -245,13 +259,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("IncidentListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -264,4 +278,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_alert_rule.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}/incidents"} # type: ignore + list_by_alert_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}/incidents" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_alert_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_alert_rules_operations.py index d457cccd45dd..b9dd1693eaca 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_alert_rules_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_alert_rules_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -42,8 +47,8 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2016-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -59,7 +64,7 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -76,7 +81,7 @@ def build_delete_request(resource_group_name: str, rule_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str + api_version: Literal["2016-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -92,7 +97,7 @@ def build_delete_request(resource_group_name: str, rule_name: str, subscription_ "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -107,7 +112,7 @@ def build_get_request(resource_group_name: str, rule_name: str, subscription_id: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str + api_version: Literal["2016-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -123,7 +128,7 @@ def build_get_request(resource_group_name: str, rule_name: str, subscription_id: "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -138,8 +143,8 @@ def build_update_request(resource_group_name: str, rule_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2016-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -155,7 +160,7 @@ def build_update_request(resource_group_name: str, rule_name: str, subscription_ "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -172,7 +177,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str + api_version: Literal["2016-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -187,7 +192,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -202,7 +207,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str + api_version: Literal["2016-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -211,7 +216,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -308,8 +313,8 @@ def create_or_update( :type resource_group_name: str :param rule_name: The name of the rule. Required. :type rule_name: str - :param parameters: The parameters of the rule to create or update. Is either a model type or a - IO type. Required. + :param parameters: The parameters of the rule to create or update. Is either a + AlertRuleResource type or a IO type. Required. :type parameters: ~$(python-base-namespace).v2016_03_01.models.AlertRuleResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -330,9 +335,9 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResource] + api_version: Literal["2016-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AlertRuleResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -355,9 +360,9 @@ def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -375,11 +380,13 @@ def create_or_update( deserialized = self._deserialize("AlertRuleResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -408,8 +415,8 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2016-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -421,9 +428,9 @@ def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -437,7 +444,9 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}" + } @distributed_trace def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _models.AlertRuleResource: @@ -464,8 +473,8 @@ def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _model _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResource] + api_version: Literal["2016-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) + cls: ClsType[_models.AlertRuleResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -477,9 +486,9 @@ def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _model params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -497,7 +506,9 @@ def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _model return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}" + } @overload def update( @@ -573,8 +584,8 @@ def update( :type resource_group_name: str :param rule_name: The name of the rule. Required. :type rule_name: str - :param alert_rules_resource: Parameters supplied to the operation. Is either a model type or a - IO type. Required. + :param alert_rules_resource: Parameters supplied to the operation. Is either a + AlertRuleResourcePatch type or a IO type. Required. :type alert_rules_resource: ~$(python-base-namespace).v2016_03_01.models.AlertRuleResourcePatch or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -596,9 +607,9 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResource] + api_version: Literal["2016-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AlertRuleResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -621,9 +632,9 @@ def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -641,11 +652,13 @@ def update( deserialized = self._deserialize("AlertRuleResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}" + } @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.AlertRuleResource"]: @@ -663,8 +676,8 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResourceCollection] + api_version: Literal["2016-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) + cls: ClsType[_models.AlertRuleResourceCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -686,16 +699,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -703,13 +723,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("AlertRuleResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -723,7 +743,9 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules" + } @distributed_trace def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.AlertRuleResource"]: @@ -738,8 +760,8 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.AlertRuleReso _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleResourceCollection] + api_version: Literal["2016-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) + cls: ClsType[_models.AlertRuleResourceCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -760,16 +782,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -777,13 +806,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("AlertRuleResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -797,4 +826,4 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/alertrules"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/alertrules"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_log_profiles_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_log_profiles_operations.py index 075e2e19ef9a..ecc665ea1b45 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_log_profiles_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_log_profiles_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -39,7 +44,7 @@ def build_delete_request(log_profile_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str + api_version: Literal["2016-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}" @@ -49,7 +54,7 @@ def build_delete_request(log_profile_name: str, subscription_id: str, **kwargs: "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -61,7 +66,7 @@ def build_get_request(log_profile_name: str, subscription_id: str, **kwargs: Any _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str + api_version: Literal["2016-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -73,7 +78,7 @@ def build_get_request(log_profile_name: str, subscription_id: str, **kwargs: Any "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -88,8 +93,8 @@ def build_create_or_update_request(log_profile_name: str, subscription_id: str, _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2016-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -101,7 +106,7 @@ def build_create_or_update_request(log_profile_name: str, subscription_id: str, "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -118,8 +123,8 @@ def build_update_request(log_profile_name: str, subscription_id: str, **kwargs: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2016-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -131,7 +136,7 @@ def build_update_request(log_profile_name: str, subscription_id: str, **kwargs: "logProfileName": _SERIALIZER.url("log_profile_name", log_profile_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -148,7 +153,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str + api_version: Literal["2016-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -157,7 +162,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -209,8 +214,8 @@ def delete(self, log_profile_name: str, **kwargs: Any) -> None: # pylint: disab _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2016-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( log_profile_name=log_profile_name, @@ -221,9 +226,9 @@ def delete(self, log_profile_name: str, **kwargs: Any) -> None: # pylint: disab params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -236,7 +241,9 @@ def delete(self, log_profile_name: str, **kwargs: Any) -> None: # pylint: disab if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}" + } @distributed_trace def get(self, log_profile_name: str, **kwargs: Any) -> _models.LogProfileResource: @@ -260,8 +267,8 @@ def get(self, log_profile_name: str, **kwargs: Any) -> _models.LogProfileResourc _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.LogProfileResource] + api_version: Literal["2016-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) + cls: ClsType[_models.LogProfileResource] = kwargs.pop("cls", None) request = build_get_request( log_profile_name=log_profile_name, @@ -272,9 +279,9 @@ def get(self, log_profile_name: str, **kwargs: Any) -> _models.LogProfileResourc params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -292,7 +299,7 @@ def get(self, log_profile_name: str, **kwargs: Any) -> _models.LogProfileResourc return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}"} @overload def create_or_update( @@ -345,8 +352,8 @@ def create_or_update( :param log_profile_name: The name of the log profile. Required. :type log_profile_name: str - :param parameters: Parameters supplied to the operation. Is either a model type or a IO type. - Required. + :param parameters: Parameters supplied to the operation. Is either a LogProfileResource type or + a IO type. Required. :type parameters: ~$(python-base-namespace).v2016_03_01.models.LogProfileResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -367,9 +374,9 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.LogProfileResource] + api_version: Literal["2016-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LogProfileResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -391,9 +398,9 @@ def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -410,7 +417,9 @@ def create_or_update( return deserialized - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}" + } @overload def update( @@ -464,8 +473,8 @@ def update( :param log_profile_name: The name of the log profile. Required. :type log_profile_name: str - :param log_profiles_resource: Parameters supplied to the operation. Is either a model type or a - IO type. Required. + :param log_profiles_resource: Parameters supplied to the operation. Is either a + LogProfileResourcePatch type or a IO type. Required. :type log_profiles_resource: ~$(python-base-namespace).v2016_03_01.models.LogProfileResourcePatch or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -487,9 +496,9 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.LogProfileResource] + api_version: Literal["2016-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LogProfileResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -511,9 +520,9 @@ def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -531,7 +540,9 @@ def update( return deserialized - update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}" + } @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.LogProfileResource"]: @@ -546,8 +557,8 @@ def list(self, **kwargs: Any) -> Iterable["_models.LogProfileResource"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.LogProfileCollection] + api_version: Literal["2016-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) + cls: ClsType[_models.LogProfileCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -568,16 +579,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -585,13 +603,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("LogProfileCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -604,4 +622,4 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_metric_definitions_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_metric_definitions_operations.py index 4a47b08855ae..62c5286e52f8 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_metric_definitions_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_metric_definitions_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,7 @@ def build_list_request(resource_uri: str, *, filter: Optional[str] = None, **kwa _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str + api_version: Literal["2016-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -49,7 +54,7 @@ def build_list_request(resource_uri: str, *, filter: Optional[str] = None, **kwa "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -105,8 +110,8 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricDefinitionCollection] + api_version: Literal["2016-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-03-01")) + cls: ClsType[_models.MetricDefinitionCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -128,16 +133,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -145,13 +157,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("MetricDefinitionCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -165,4 +177,4 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/metricDefinitions"} # type: ignore + list.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/metricDefinitions"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/__init__.py index 8ba4823444a9..2c7733bfd566 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/__init__.py @@ -13,12 +13,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["MonitorManagementClient"] +__all__ = [ + "MonitorManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_configuration.py index e8402d49e16b..b01c661afc04 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -34,7 +40,7 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2016-09-01") # type: str + api_version: Literal["2016-09-01"] = kwargs.pop("api_version", "2016-09-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -45,10 +51,7 @@ def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, **kwargs # type: Any - ): - # type: (...) -> None + def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_metadata.json index dd87cd1bcd39..43644548c2d7 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_metadata.json @@ -19,7 +19,8 @@ "signature": "credential: \"TokenCredential\",", "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true + "required": true, + "method_location": "positional" } }, "async": { @@ -36,22 +37,25 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "signature": "api_version: Optional[str]=None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } }, "async": { @@ -59,19 +63,22 @@ "signature": "api_version: Optional[str] = None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { "signature": "profile: KnownProfiles = KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } } } @@ -88,4 +95,4 @@ "metrics": "MetricsOperations", "service_diagnostic_settings": "ServiceDiagnosticSettingsOperations" } -} \ No newline at end of file +} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_monitor_management_client.py index 5923e0722f61..f9803708ac98 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_monitor_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from . import models +from . import models as _models from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import MetricsOperations, ServiceDiagnosticSettingsOperations @@ -45,7 +45,7 @@ def __init__( self._config = MonitorManagementClientConfiguration(credential=credential, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -76,15 +76,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> MonitorManagementClient + def __enter__(self) -> "MonitorManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_vendor.py index 9aad73fc743e..bd0df84f5319 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_vendor.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_vendor.py @@ -5,6 +5,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import List, cast + from azure.core.pipeline.transport import HttpRequest @@ -22,6 +24,7 @@ def _format_url_section(template, **kwargs): try: return template.format(**kwargs) except KeyError as key: - formatted_components = template.split("/") + # Need the cast, as for some reasons "split" is typed as list[str | Any] + formatted_components = cast(List[str], template.split("/")) components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_version.py index ce9ac7ae37b3..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/__init__.py index 8638dc69d869..2c151bb41c19 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/__init__.py @@ -10,12 +10,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["MonitorManagementClient"] +__all__ = [ + "MonitorManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/_configuration.py index 3cda5da22161..cf31f284f0d8 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -34,7 +40,7 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2016-09-01") # type: str + api_version: Literal["2016-09-01"] = kwargs.pop("api_version", "2016-09-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/_monitor_management_client.py index 2dd6e4fc91b4..b0cf7172752f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/_monitor_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from .. import models +from .. import models as _models from ..._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import MetricsOperations, ServiceDiagnosticSettingsOperations @@ -45,7 +45,7 @@ def __init__( self._config = MonitorManagementClientConfiguration(credential=credential, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -83,5 +83,5 @@ async def __aenter__(self) -> "MonitorManagementClient": await self._client.__aenter__() return self - async def __aexit__(self, *exc_details) -> None: + async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/operations/__init__.py index a619a5adabf7..ba50816b0687 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/operations/__init__.py @@ -10,7 +10,7 @@ from ._service_diagnostic_settings_operations import ServiceDiagnosticSettingsOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/operations/_metrics_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/operations/_metrics_operations.py index 7b4c42edd489..3eb1eb9a5c32 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/operations/_metrics_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/operations/_metrics_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -29,6 +30,10 @@ from ..._vendor import _convert_request from ...operations._metrics_operations import build_list_request +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -86,8 +91,8 @@ def list(self, resource_uri: str, filter: Optional[str] = None, **kwargs: Any) - _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricCollection] + api_version: Literal["2016-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) + cls: ClsType[_models.MetricCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -109,16 +114,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -126,13 +138,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("MetricCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -146,4 +158,4 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/metrics"} # type: ignore + list.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/metrics"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/operations/_service_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/operations/_service_diagnostic_settings_operations.py index 3094d2458c83..e75caff657c5 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/operations/_service_diagnostic_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/operations/_service_diagnostic_settings_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -31,6 +32,10 @@ build_update_request, ) +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -77,8 +82,8 @@ async def get(self, resource_uri: str, **kwargs: Any) -> _models.ServiceDiagnost _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceDiagnosticSettingsResource] + api_version: Literal["2016-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) + cls: ClsType[_models.ServiceDiagnosticSettingsResource] = kwargs.pop("cls", None) request = build_get_request( resource_uri=resource_uri, @@ -88,9 +93,9 @@ async def get(self, resource_uri: str, **kwargs: Any) -> _models.ServiceDiagnost params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -108,7 +113,7 @@ async def get(self, resource_uri: str, **kwargs: Any) -> _models.ServiceDiagnost return deserialized - get.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service"} # type: ignore + get.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service"} @overload async def create_or_update( @@ -165,8 +170,8 @@ async def create_or_update( :param resource_uri: The identifier of the resource. Required. :type resource_uri: str - :param parameters: Parameters supplied to the operation. Is either a model type or a IO type. - Required. + :param parameters: Parameters supplied to the operation. Is either a + ServiceDiagnosticSettingsResource type or a IO type. Required. :type parameters: ~$(python-base-namespace).v2016_09_01.models.ServiceDiagnosticSettingsResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -188,9 +193,9 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceDiagnosticSettingsResource] + api_version: Literal["2016-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ServiceDiagnosticSettingsResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -211,9 +216,9 @@ async def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -230,7 +235,7 @@ async def create_or_update( return deserialized - create_or_update.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service"} # type: ignore + create_or_update.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service"} @overload async def update( @@ -296,7 +301,7 @@ async def update( :param resource_uri: The identifier of the resource. Required. :type resource_uri: str :param service_diagnostic_settings_resource: Parameters supplied to the operation. Is either a - model type or a IO type. Required. + ServiceDiagnosticSettingsResourcePatch type or a IO type. Required. :type service_diagnostic_settings_resource: ~$(python-base-namespace).v2016_09_01.models.ServiceDiagnosticSettingsResourcePatch or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -318,9 +323,9 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceDiagnosticSettingsResource] + api_version: Literal["2016-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ServiceDiagnosticSettingsResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -341,9 +346,9 @@ async def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -361,4 +366,4 @@ async def update( return deserialized - update.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service"} # type: ignore + update.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/__init__.py index 06c53293c351..6404a337a3f8 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/__init__.py @@ -20,7 +20,7 @@ from ._monitor_management_client_enums import Unit from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/_models_py3.py index 0ac41d3a67c1..240a0a582827 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/_models_py3.py @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, TYPE_CHECKING, Union +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union from ... import _serialization @@ -31,7 +31,7 @@ class ErrorResponse(_serialization.Model): "message": {"key": "message", "type": "str"}, } - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: """ :keyword code: Error code. :paramtype code: str @@ -63,7 +63,7 @@ class LocalizableString(_serialization.Model): "localized_value": {"key": "localizedValue", "type": "str"}, } - def __init__(self, *, value: str, localized_value: Optional[str] = None, **kwargs): + def __init__(self, *, value: str, localized_value: Optional[str] = None, **kwargs: Any) -> None: """ :keyword value: the invariant value. Required. :paramtype value: str @@ -106,8 +106,8 @@ def __init__( enabled: bool, category: Optional[str] = None, retention_policy: Optional["_models.RetentionPolicy"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword category: Name of a Diagnostic Log category for a resource type this setting is applied to. To obtain the list of Diagnostic Log categories for a resource, first perform a GET @@ -166,8 +166,8 @@ def __init__( data: List["_models.MetricValue"], id: Optional[str] = None, # pylint: disable=redefined-builtin type: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword id: the id, resourceId, of the metric. :paramtype id: str @@ -208,7 +208,7 @@ class MetricCollection(_serialization.Model): "value": {"key": "value", "type": "[Metric]"}, } - def __init__(self, *, value: List["_models.Metric"], **kwargs): + def __init__(self, *, value: List["_models.Metric"], **kwargs: Any) -> None: """ :keyword value: the value of the collection. Required. :paramtype value: list[~$(python-base-namespace).v2016_09_01.models.Metric] @@ -247,8 +247,8 @@ def __init__( time_grain: datetime.timedelta, enabled: bool, retention_policy: Optional["_models.RetentionPolicy"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword time_grain: the timegrain of the metric in ISO8601 format. Required. :paramtype time_grain: ~datetime.timedelta @@ -305,8 +305,8 @@ def __init__( maximum: Optional[float] = None, total: Optional[float] = None, count: Optional[int] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword time_stamp: the timestamp for the metric value in ISO 8601 format. Required. :paramtype time_stamp: ~datetime.datetime @@ -365,7 +365,7 @@ class Resource(_serialization.Model): "tags": {"key": "tags", "type": "{str}"}, } - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: """ :keyword location: Resource location. Required. :paramtype location: str @@ -402,7 +402,7 @@ class RetentionPolicy(_serialization.Model): "days": {"key": "days", "type": "int"}, } - def __init__(self, *, enabled: bool, days: int, **kwargs): + def __init__(self, *, enabled: bool, days: int, **kwargs: Any) -> None: """ :keyword enabled: a value indicating whether the retention policy is enabled. Required. :paramtype enabled: bool @@ -484,8 +484,8 @@ def __init__( metrics: Optional[List["_models.MetricSettings"]] = None, logs: Optional[List["_models.LogSettings"]] = None, workspace_id: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword location: Resource location. Required. :paramtype location: str @@ -564,8 +564,8 @@ def __init__( metrics: Optional[List["_models.MetricSettings"]] = None, logs: Optional[List["_models.LogSettings"]] = None, workspace_id: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword tags: Resource tags. :paramtype tags: dict[str, str] diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/operations/__init__.py index a619a5adabf7..ba50816b0687 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/operations/__init__.py @@ -10,7 +10,7 @@ from ._service_diagnostic_settings_operations import ServiceDiagnosticSettingsOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/operations/_metrics_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/operations/_metrics_operations.py index 18a45a88b7f0..16fc1d5cbe79 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/operations/_metrics_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/operations/_metrics_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,7 @@ def build_list_request(resource_uri: str, *, filter: Optional[str] = None, **kwa _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + api_version: Literal["2016-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -49,7 +54,7 @@ def build_list_request(resource_uri: str, *, filter: Optional[str] = None, **kwa "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters if filter is not None: @@ -114,8 +119,8 @@ def list(self, resource_uri: str, filter: Optional[str] = None, **kwargs: Any) - _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricCollection] + api_version: Literal["2016-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) + cls: ClsType[_models.MetricCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -137,16 +142,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -154,13 +166,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("MetricCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -174,4 +186,4 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/metrics"} # type: ignore + list.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/metrics"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/operations/_service_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/operations/_service_diagnostic_settings_operations.py index c7e853360abd..9316c2ab7273 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/operations/_service_diagnostic_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/operations/_service_diagnostic_settings_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -27,6 +28,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -38,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 = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str + api_version: Literal["2016-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -47,7 +52,7 @@ def build_get_request(resource_uri: str, **kwargs: Any) -> HttpRequest: "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -62,8 +67,8 @@ 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 = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2016-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -72,7 +77,7 @@ def build_create_or_update_request(resource_uri: str, **kwargs: Any) -> HttpRequ "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -89,8 +94,8 @@ 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 = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2016-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -99,7 +104,7 @@ def build_update_request(resource_uri: str, **kwargs: Any) -> HttpRequest: "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -154,8 +159,8 @@ def get(self, resource_uri: str, **kwargs: Any) -> _models.ServiceDiagnosticSett _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceDiagnosticSettingsResource] + api_version: Literal["2016-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) + cls: ClsType[_models.ServiceDiagnosticSettingsResource] = kwargs.pop("cls", None) request = build_get_request( resource_uri=resource_uri, @@ -165,9 +170,9 @@ def get(self, resource_uri: str, **kwargs: Any) -> _models.ServiceDiagnosticSett params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -185,7 +190,7 @@ def get(self, resource_uri: str, **kwargs: Any) -> _models.ServiceDiagnosticSett return deserialized - get.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service"} # type: ignore + get.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service"} @overload def create_or_update( @@ -242,8 +247,8 @@ def create_or_update( :param resource_uri: The identifier of the resource. Required. :type resource_uri: str - :param parameters: Parameters supplied to the operation. Is either a model type or a IO type. - Required. + :param parameters: Parameters supplied to the operation. Is either a + ServiceDiagnosticSettingsResource type or a IO type. Required. :type parameters: ~$(python-base-namespace).v2016_09_01.models.ServiceDiagnosticSettingsResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -265,9 +270,9 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceDiagnosticSettingsResource] + api_version: Literal["2016-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ServiceDiagnosticSettingsResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -288,9 +293,9 @@ def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -307,7 +312,7 @@ def create_or_update( return deserialized - create_or_update.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service"} # type: ignore + create_or_update.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service"} @overload def update( @@ -373,7 +378,7 @@ def update( :param resource_uri: The identifier of the resource. Required. :type resource_uri: str :param service_diagnostic_settings_resource: Parameters supplied to the operation. Is either a - model type or a IO type. Required. + ServiceDiagnosticSettingsResourcePatch type or a IO type. Required. :type service_diagnostic_settings_resource: ~$(python-base-namespace).v2016_09_01.models.ServiceDiagnosticSettingsResourcePatch or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -395,9 +400,9 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ServiceDiagnosticSettingsResource] + api_version: Literal["2016-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2016-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ServiceDiagnosticSettingsResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -418,9 +423,9 @@ def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -438,4 +443,4 @@ def update( return deserialized - update.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service"} # type: ignore + update.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/__init__.py index 8ba4823444a9..2c7733bfd566 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/__init__.py @@ -13,12 +13,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["MonitorManagementClient"] +__all__ = [ + "MonitorManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_configuration.py index c54e5adef4db..84b48bb6a7a5 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -36,7 +42,7 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2017-03-01-preview") # type: str + api_version: Literal["2017-03-01-preview"] = kwargs.pop("api_version", "2017-03-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -50,10 +56,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, **kwargs # type: Any - ): - # type: (...) -> None + def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_metadata.json index c74234f8fa0c..9efc7cb572fe 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_metadata.json @@ -19,13 +19,15 @@ "signature": "credential: \"TokenCredential\",", "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true + "required": true, + "method_location": "positional" }, "subscription_id": { "signature": "subscription_id: str,", "description": "The ID of the target subscription. Required.", "docstring_type": "str", - "required": true + "required": true, + "method_location": "positional" } }, "async": { @@ -48,22 +50,25 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "signature": "api_version: Optional[str]=None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } }, "async": { @@ -71,19 +76,22 @@ "signature": "api_version: Optional[str] = None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { "signature": "profile: KnownProfiles = KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } } } @@ -99,4 +107,4 @@ "operation_groups": { "activity_log_alerts": "ActivityLogAlertsOperations" } -} \ No newline at end of file +} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_monitor_management_client.py index 34d0b77392aa..a7507544f1be 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_monitor_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from . import models +from . import models as _models from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ActivityLogAlertsOperations @@ -51,7 +51,7 @@ def __init__( ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -81,15 +81,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> MonitorManagementClient + def __enter__(self) -> "MonitorManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_vendor.py index 9aad73fc743e..bd0df84f5319 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_vendor.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_vendor.py @@ -5,6 +5,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import List, cast + from azure.core.pipeline.transport import HttpRequest @@ -22,6 +24,7 @@ def _format_url_section(template, **kwargs): try: return template.format(**kwargs) except KeyError as key: - formatted_components = template.split("/") + # Need the cast, as for some reasons "split" is typed as list[str | Any] + formatted_components = cast(List[str], template.split("/")) components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_version.py index ce9ac7ae37b3..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/__init__.py index 8638dc69d869..2c151bb41c19 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/__init__.py @@ -10,12 +10,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["MonitorManagementClient"] +__all__ = [ + "MonitorManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/_configuration.py index a539a0d703fa..4cde3faf0edc 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -36,7 +42,7 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2017-03-01-preview") # type: str + api_version: Literal["2017-03-01-preview"] = kwargs.pop("api_version", "2017-03-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/_monitor_management_client.py index 203cca5d1590..bc117e468c6b 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/_monitor_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from .. import models +from .. import models as _models from ..._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ActivityLogAlertsOperations @@ -51,7 +51,7 @@ def __init__( ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -88,5 +88,5 @@ async def __aenter__(self) -> "MonitorManagementClient": await self._client.__aenter__() return self - async def __aexit__(self, *exc_details) -> None: + async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/operations/__init__.py index 605798ce7feb..b024a2af0682 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/operations/__init__.py @@ -9,7 +9,7 @@ from ._activity_log_alerts_operations import ActivityLogAlertsOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/operations/_activity_log_alerts_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/operations/_activity_log_alerts_operations.py index e5a8a7ff0c82..fe83924fb2d8 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/operations/_activity_log_alerts_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/operations/_activity_log_alerts_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -37,6 +38,10 @@ build_update_request, ) +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -133,7 +138,7 @@ async def create_or_update( :param activity_log_alert_name: The name of the activity log alert. Required. :type activity_log_alert_name: str :param activity_log_alert: The activity log alert to create or use for the update. Is either a - model type or a IO type. Required. + ActivityLogAlertResource type or a IO type. Required. :type activity_log_alert: ~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -155,9 +160,11 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActivityLogAlertResource] + api_version: Literal["2017-03-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-03-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ActivityLogAlertResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -180,9 +187,9 @@ async def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -200,11 +207,13 @@ async def create_or_update( deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}" + } @distributed_trace_async async def get( @@ -233,8 +242,10 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActivityLogAlertResource] + api_version: Literal["2017-03-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-03-01-preview") + ) + cls: ClsType[_models.ActivityLogAlertResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -246,9 +257,9 @@ async def get( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -266,7 +277,9 @@ async def get( return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -295,8 +308,10 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2017-03-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-03-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -308,9 +323,9 @@ async def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -324,7 +339,9 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}" + } @overload async def update( @@ -401,8 +418,8 @@ async def update( :type resource_group_name: str :param activity_log_alert_name: The name of the activity log alert. Required. :type activity_log_alert_name: str - :param activity_log_alert_patch: Parameters supplied to the operation. Is either a model type - or a IO type. Required. + :param activity_log_alert_patch: Parameters supplied to the operation. Is either a + ActivityLogAlertResourcePatch type or a IO type. Required. :type activity_log_alert_patch: ~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertResourcePatch or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -424,9 +441,11 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActivityLogAlertResource] + api_version: Literal["2017-03-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-03-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ActivityLogAlertResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -449,9 +468,9 @@ async def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -469,7 +488,9 @@ async def update( return deserialized - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}" + } @distributed_trace def list_by_subscription_id(self, **kwargs: Any) -> AsyncIterable["_models.ActivityLogAlertResource"]: @@ -485,8 +506,10 @@ def list_by_subscription_id(self, **kwargs: Any) -> AsyncIterable["_models.Activ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActivityLogAlertList] + api_version: Literal["2017-03-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-03-01-preview") + ) + cls: ClsType[_models.ActivityLogAlertList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -507,16 +530,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -524,13 +554,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ActivityLogAlertList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -544,7 +574,9 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_subscription_id.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/activityLogAlerts"} # type: ignore + list_by_subscription_id.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/activityLogAlerts" + } @distributed_trace def list_by_resource_group( @@ -565,8 +597,10 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActivityLogAlertList] + api_version: Literal["2017-03-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-03-01-preview") + ) + cls: ClsType[_models.ActivityLogAlertList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -588,16 +622,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -605,13 +646,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ActivityLogAlertList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -625,4 +666,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/models/__init__.py index e51b06f64508..0ca76e5f619d 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/models/__init__.py @@ -16,7 +16,7 @@ from ._models_py3 import ErrorResponse from ._models_py3 import Resource from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/models/_models_py3.py index e3f5abc767fd..69174c882a31 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/models/_models_py3.py @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Dict, List, Optional, TYPE_CHECKING +from typing import Any, Dict, List, Optional, TYPE_CHECKING from ... import _serialization @@ -38,7 +38,9 @@ class ActivityLogAlertActionGroup(_serialization.Model): "webhook_properties": {"key": "webhookProperties", "type": "{str}"}, } - def __init__(self, *, action_group_id: str, webhook_properties: Optional[Dict[str, str]] = None, **kwargs): + def __init__( + self, *, action_group_id: str, webhook_properties: Optional[Dict[str, str]] = None, **kwargs: Any + ) -> None: """ :keyword action_group_id: The resourceId of the action group. This cannot be null or empty. Required. @@ -64,7 +66,9 @@ class ActivityLogAlertActionList(_serialization.Model): "action_groups": {"key": "actionGroups", "type": "[ActivityLogAlertActionGroup]"}, } - def __init__(self, *, action_groups: Optional[List["_models.ActivityLogAlertActionGroup"]] = None, **kwargs): + def __init__( + self, *, action_groups: Optional[List["_models.ActivityLogAlertActionGroup"]] = None, **kwargs: Any + ) -> None: """ :keyword action_groups: The list of activity log alerts. :paramtype action_groups: @@ -92,7 +96,7 @@ class ActivityLogAlertAllOfCondition(_serialization.Model): "all_of": {"key": "allOf", "type": "[ActivityLogAlertLeafCondition]"}, } - def __init__(self, *, all_of: List["_models.ActivityLogAlertLeafCondition"], **kwargs): + def __init__(self, *, all_of: List["_models.ActivityLogAlertLeafCondition"], **kwargs: Any) -> None: """ :keyword all_of: The list of activity log alert conditions. Required. :paramtype all_of: @@ -127,7 +131,7 @@ class ActivityLogAlertLeafCondition(_serialization.Model): "equals": {"key": "equals", "type": "str"}, } - def __init__(self, *, field: str, equals: str, **kwargs): + def __init__(self, *, field: str, equals: str, **kwargs: Any) -> None: """ :keyword field: The name of the field that this condition will examine. The possible values for this field are (case-insensitive): 'resourceId', 'category', 'caller', 'level', @@ -155,7 +159,7 @@ class ActivityLogAlertList(_serialization.Model): "value": {"key": "value", "type": "[ActivityLogAlertResource]"}, } - def __init__(self, *, value: Optional[List["_models.ActivityLogAlertResource"]] = None, **kwargs): + def __init__(self, *, value: Optional[List["_models.ActivityLogAlertResource"]] = None, **kwargs: Any) -> None: """ :keyword value: The list of activity log alerts. :paramtype value: @@ -199,7 +203,7 @@ class Resource(_serialization.Model): "tags": {"key": "tags", "type": "{str}"}, } - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: """ :keyword location: Resource location. Required. :paramtype location: str @@ -278,8 +282,8 @@ def __init__( condition: Optional["_models.ActivityLogAlertAllOfCondition"] = None, actions: Optional["_models.ActivityLogAlertActionList"] = None, description: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword location: Resource location. Required. :paramtype location: str @@ -347,7 +351,9 @@ class ActivityLogAlertResourcePatch(Resource): "enabled": {"key": "properties.enabled", "type": "bool"}, } - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, enabled: bool = True, **kwargs): + def __init__( + self, *, location: str, tags: Optional[Dict[str, str]] = None, enabled: bool = True, **kwargs: Any + ) -> None: """ :keyword location: Resource location. Required. :paramtype location: str @@ -375,7 +381,7 @@ class ErrorResponse(_serialization.Model): "message": {"key": "message", "type": "str"}, } - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: """ :keyword code: Error code. :paramtype code: str diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/operations/__init__.py index 605798ce7feb..b024a2af0682 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/operations/__init__.py @@ -9,7 +9,7 @@ from ._activity_log_alerts_operations import ActivityLogAlertsOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/operations/_activity_log_alerts_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/operations/_activity_log_alerts_operations.py index 71d2e102308f..0875be88f0a4 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/operations/_activity_log_alerts_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/operations/_activity_log_alerts_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -42,8 +47,10 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2017-03-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-03-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -59,7 +66,7 @@ def build_create_or_update_request( "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -78,7 +85,9 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01-preview")) # type: str + api_version: Literal["2017-03-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-03-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -94,7 +103,7 @@ def build_get_request( "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -111,7 +120,9 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01-preview")) # type: str + api_version: Literal["2017-03-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-03-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -127,7 +138,7 @@ def build_delete_request( "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -144,8 +155,10 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2017-03-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-03-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -161,7 +174,7 @@ def build_update_request( "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -178,7 +191,9 @@ def build_list_by_subscription_id_request(subscription_id: str, **kwargs: Any) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01-preview")) # type: str + api_version: Literal["2017-03-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-03-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -187,7 +202,7 @@ def build_list_by_subscription_id_request(subscription_id: str, **kwargs: Any) - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -202,7 +217,9 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01-preview")) # type: str + api_version: Literal["2017-03-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-03-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -217,7 +234,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -320,7 +337,7 @@ def create_or_update( :param activity_log_alert_name: The name of the activity log alert. Required. :type activity_log_alert_name: str :param activity_log_alert: The activity log alert to create or use for the update. Is either a - model type or a IO type. Required. + ActivityLogAlertResource type or a IO type. Required. :type activity_log_alert: ~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -342,9 +359,11 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActivityLogAlertResource] + api_version: Literal["2017-03-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-03-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ActivityLogAlertResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -367,9 +386,9 @@ def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -387,11 +406,13 @@ def create_or_update( deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}" + } @distributed_trace def get( @@ -420,8 +441,10 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActivityLogAlertResource] + api_version: Literal["2017-03-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-03-01-preview") + ) + cls: ClsType[_models.ActivityLogAlertResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -433,9 +456,9 @@ def get( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -453,7 +476,9 @@ def get( return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -482,8 +507,10 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2017-03-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-03-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -495,9 +522,9 @@ def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -511,7 +538,9 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}" + } @overload def update( @@ -588,8 +617,8 @@ def update( :type resource_group_name: str :param activity_log_alert_name: The name of the activity log alert. Required. :type activity_log_alert_name: str - :param activity_log_alert_patch: Parameters supplied to the operation. Is either a model type - or a IO type. Required. + :param activity_log_alert_patch: Parameters supplied to the operation. Is either a + ActivityLogAlertResourcePatch type or a IO type. Required. :type activity_log_alert_patch: ~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertResourcePatch or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -611,9 +640,11 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActivityLogAlertResource] + api_version: Literal["2017-03-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-03-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ActivityLogAlertResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -636,9 +667,9 @@ def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -656,7 +687,9 @@ def update( return deserialized - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}" + } @distributed_trace def list_by_subscription_id(self, **kwargs: Any) -> Iterable["_models.ActivityLogAlertResource"]: @@ -672,8 +705,10 @@ def list_by_subscription_id(self, **kwargs: Any) -> Iterable["_models.ActivityLo _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActivityLogAlertList] + api_version: Literal["2017-03-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-03-01-preview") + ) + cls: ClsType[_models.ActivityLogAlertList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -694,16 +729,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -711,13 +753,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ActivityLogAlertList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -731,7 +773,9 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_subscription_id.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/activityLogAlerts"} # type: ignore + list_by_subscription_id.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/activityLogAlerts" + } @distributed_trace def list_by_resource_group( @@ -752,8 +796,10 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-03-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActivityLogAlertList] + api_version: Literal["2017-03-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-03-01-preview") + ) + cls: ClsType[_models.ActivityLogAlertList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -775,16 +821,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -792,13 +845,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ActivityLogAlertList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -812,4 +865,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/__init__.py index 8ba4823444a9..2c7733bfd566 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/__init__.py @@ -13,12 +13,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["MonitorManagementClient"] +__all__ = [ + "MonitorManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_configuration.py index 84143abad445..1d781d6471a4 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -36,7 +42,7 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2017-04-01") # type: str + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", "2017-04-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -50,10 +56,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, **kwargs # type: Any - ): - # type: (...) -> None + def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_metadata.json index dae78253fff5..6eaf6b014379 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_metadata.json @@ -19,13 +19,15 @@ "signature": "credential: \"TokenCredential\",", "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true + "required": true, + "method_location": "positional" }, "subscription_id": { "signature": "subscription_id: str,", "description": "The ID of the target subscription. Required.", "docstring_type": "str", - "required": true + "required": true, + "method_location": "positional" } }, "async": { @@ -48,22 +50,25 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "signature": "api_version: Optional[str]=None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } }, "async": { @@ -71,19 +76,22 @@ "signature": "api_version: Optional[str] = None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { "signature": "profile: KnownProfiles = KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } } } @@ -100,4 +108,4 @@ "action_groups": "ActionGroupsOperations", "activity_log_alerts": "ActivityLogAlertsOperations" } -} \ No newline at end of file +} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_monitor_management_client.py index 79baafaa5c1d..6e7e6e46fa70 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_monitor_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from . import models +from . import models as _models from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ActionGroupsOperations, ActivityLogAlertsOperations @@ -53,7 +53,7 @@ def __init__( ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -84,15 +84,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> MonitorManagementClient + def __enter__(self) -> "MonitorManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_vendor.py index 9aad73fc743e..bd0df84f5319 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_vendor.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_vendor.py @@ -5,6 +5,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import List, cast + from azure.core.pipeline.transport import HttpRequest @@ -22,6 +24,7 @@ def _format_url_section(template, **kwargs): try: return template.format(**kwargs) except KeyError as key: - formatted_components = template.split("/") + # Need the cast, as for some reasons "split" is typed as list[str | Any] + formatted_components = cast(List[str], template.split("/")) components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_version.py index ce9ac7ae37b3..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/__init__.py index 8638dc69d869..2c151bb41c19 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/__init__.py @@ -10,12 +10,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["MonitorManagementClient"] +__all__ = [ + "MonitorManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/_configuration.py index e23fd4940527..1816576cd041 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -36,7 +42,7 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2017-04-01") # type: str + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", "2017-04-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/_monitor_management_client.py index 8a28d2c6a341..051e764b8945 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/_monitor_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from .. import models +from .. import models as _models from ..._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ActionGroupsOperations, ActivityLogAlertsOperations @@ -54,7 +54,7 @@ def __init__( ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -92,5 +92,5 @@ async def __aenter__(self) -> "MonitorManagementClient": await self._client.__aenter__() return self - async def __aexit__(self, *exc_details) -> None: + async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/operations/__init__.py index 6e24b5fe0a02..204d3d1aa9c7 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/operations/__init__.py @@ -10,7 +10,7 @@ from ._activity_log_alerts_operations import ActivityLogAlertsOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/operations/_action_groups_operations.py index 9955c1eb19c7..cf5f7329c8cd 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/operations/_action_groups_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/operations/_action_groups_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -38,6 +39,10 @@ build_update_request, ) +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -132,8 +137,8 @@ async def create_or_update( :type resource_group_name: str :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group: The action group to create or use for the update. Is either a model type - or a IO type. Required. + :param action_group: The action group to create or use for the update. Is either a + ActionGroupResource type or a IO type. Required. :type action_group: ~$(python-base-namespace).v2017_04_01.models.ActionGroupResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -154,9 +159,9 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -179,9 +184,9 @@ async def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -199,11 +204,13 @@ async def create_or_update( deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" + } @distributed_trace_async async def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) -> _models.ActionGroupResource: @@ -230,8 +237,8 @@ async def get(self, resource_group_name: str, action_group_name: str, **kwargs: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -243,9 +250,9 @@ async def get(self, resource_group_name: str, action_group_name: str, **kwargs: params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -263,7 +270,9 @@ async def get(self, resource_group_name: str, action_group_name: str, **kwargs: return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -292,8 +301,8 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -305,9 +314,9 @@ async def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -321,7 +330,9 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" + } @overload async def update( @@ -394,8 +405,8 @@ async def update( :type resource_group_name: str :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Is either a model type or a IO - type. Required. + :param action_group_patch: Parameters supplied to the operation. Is either a + ActionGroupPatchBody type or a IO type. Required. :type action_group_patch: ~$(python-base-namespace).v2017_04_01.models.ActionGroupPatchBody or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -417,9 +428,9 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -442,9 +453,9 @@ async def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -462,7 +473,9 @@ async def update( return deserialized - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" + } @distributed_trace def list_by_subscription_id(self, **kwargs: Any) -> AsyncIterable["_models.ActionGroupResource"]: @@ -477,8 +490,8 @@ def list_by_subscription_id(self, **kwargs: Any) -> AsyncIterable["_models.Actio _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -499,16 +512,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -516,13 +536,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ActionGroupList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -536,7 +556,9 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_subscription_id.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups"} # type: ignore + list_by_subscription_id.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups" + } @distributed_trace def list_by_resource_group( @@ -556,8 +578,8 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -579,16 +601,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -596,13 +625,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ActionGroupList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -616,7 +645,9 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups" + } @overload async def enable_receiver( # pylint: disable=inconsistent-return-statements @@ -692,7 +723,7 @@ async def enable_receiver( # pylint: disable=inconsistent-return-statements :type resource_group_name: str :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param enable_request: The receiver to re-enable. Is either a model type or a IO type. + :param enable_request: The receiver to re-enable. Is either a EnableRequest type or a IO type. Required. :type enable_request: ~$(python-base-namespace).v2017_04_01.models.EnableRequest or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -714,9 +745,9 @@ async def enable_receiver( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -739,9 +770,9 @@ async def enable_receiver( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -755,4 +786,6 @@ async def enable_receiver( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - enable_receiver.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe"} # type: ignore + enable_receiver.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/operations/_activity_log_alerts_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/operations/_activity_log_alerts_operations.py index 4a43ed6c1b00..7998ef5b28ba 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/operations/_activity_log_alerts_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/operations/_activity_log_alerts_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -37,6 +38,10 @@ build_update_request, ) +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -132,7 +137,7 @@ async def create_or_update( :param activity_log_alert_name: The name of the activity log alert. Required. :type activity_log_alert_name: str :param activity_log_alert: The activity log alert to create or use for the update. Is either a - model type or a IO type. Required. + ActivityLogAlertResource type or a IO type. Required. :type activity_log_alert: ~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -154,9 +159,9 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActivityLogAlertResource] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ActivityLogAlertResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -179,9 +184,9 @@ async def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -199,11 +204,13 @@ async def create_or_update( deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}" + } @distributed_trace_async async def get( @@ -232,8 +239,8 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActivityLogAlertResource] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.ActivityLogAlertResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -245,9 +252,9 @@ async def get( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -265,7 +272,9 @@ async def get( return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -294,8 +303,8 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -307,9 +316,9 @@ async def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -323,7 +332,9 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}" + } @overload async def update( @@ -400,8 +411,8 @@ async def update( :type resource_group_name: str :param activity_log_alert_name: The name of the activity log alert. Required. :type activity_log_alert_name: str - :param activity_log_alert_patch: Parameters supplied to the operation. Is either a model type - or a IO type. Required. + :param activity_log_alert_patch: Parameters supplied to the operation. Is either a + ActivityLogAlertPatchBody type or a IO type. Required. :type activity_log_alert_patch: ~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertPatchBody or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -423,9 +434,9 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActivityLogAlertResource] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ActivityLogAlertResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -448,9 +459,9 @@ async def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -468,7 +479,9 @@ async def update( return deserialized - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}" + } @distributed_trace def list_by_subscription_id(self, **kwargs: Any) -> AsyncIterable["_models.ActivityLogAlertResource"]: @@ -484,8 +497,8 @@ def list_by_subscription_id(self, **kwargs: Any) -> AsyncIterable["_models.Activ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActivityLogAlertList] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.ActivityLogAlertList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -506,16 +519,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -523,13 +543,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ActivityLogAlertList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -543,7 +563,9 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_subscription_id.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/activityLogAlerts"} # type: ignore + list_by_subscription_id.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/activityLogAlerts" + } @distributed_trace def list_by_resource_group( @@ -564,8 +586,8 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActivityLogAlertList] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.ActivityLogAlertList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -587,16 +609,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -604,13 +633,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ActivityLogAlertList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -624,4 +653,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/models/__init__.py index 5d72089a83ec..353a71918f69 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/models/__init__.py @@ -28,7 +28,7 @@ from ._monitor_management_client_enums import ReceiverStatus from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/models/_models_py3.py index 4766bbaa6165..0196034e2d72 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/models/_models_py3.py @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Dict, List, Optional, TYPE_CHECKING +from typing import Any, Dict, List, Optional, TYPE_CHECKING from ... import _serialization @@ -31,8 +31,12 @@ class ActionGroupList(_serialization.Model): } def __init__( - self, *, value: Optional[List["_models.ActionGroupResource"]] = None, next_link: Optional[str] = None, **kwargs - ): + self, + *, + value: Optional[List["_models.ActionGroupResource"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: """ :keyword value: The list of action groups. :paramtype value: list[~$(python-base-namespace).v2017_04_01.models.ActionGroupResource] @@ -59,7 +63,7 @@ class ActionGroupPatchBody(_serialization.Model): "enabled": {"key": "properties.enabled", "type": "bool"}, } - def __init__(self, *, tags: Optional[Dict[str, str]] = None, enabled: bool = True, **kwargs): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, enabled: bool = True, **kwargs: Any) -> None: """ :keyword tags: Resource tags. :paramtype tags: dict[str, str] @@ -106,7 +110,7 @@ class Resource(_serialization.Model): "tags": {"key": "tags", "type": "{str}"}, } - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: """ :keyword location: Resource location. Required. :paramtype location: str @@ -201,8 +205,8 @@ def __init__( itsm_receivers: Optional[List["_models.ItsmReceiver"]] = None, azure_app_push_receivers: Optional[List["_models.AzureAppPushReceiver"]] = None, automation_runbook_receivers: Optional[List["_models.AutomationRunbookReceiver"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword location: Resource location. Required. :paramtype location: str @@ -265,7 +269,9 @@ class ActivityLogAlertActionGroup(_serialization.Model): "webhook_properties": {"key": "webhookProperties", "type": "{str}"}, } - def __init__(self, *, action_group_id: str, webhook_properties: Optional[Dict[str, str]] = None, **kwargs): + def __init__( + self, *, action_group_id: str, webhook_properties: Optional[Dict[str, str]] = None, **kwargs: Any + ) -> None: """ :keyword action_group_id: The resourceId of the action group. This cannot be null or empty. Required. @@ -291,7 +297,9 @@ class ActivityLogAlertActionList(_serialization.Model): "action_groups": {"key": "actionGroups", "type": "[ActivityLogAlertActionGroup]"}, } - def __init__(self, *, action_groups: Optional[List["_models.ActivityLogAlertActionGroup"]] = None, **kwargs): + def __init__( + self, *, action_groups: Optional[List["_models.ActivityLogAlertActionGroup"]] = None, **kwargs: Any + ) -> None: """ :keyword action_groups: The list of activity log alerts. :paramtype action_groups: @@ -319,7 +327,7 @@ class ActivityLogAlertAllOfCondition(_serialization.Model): "all_of": {"key": "allOf", "type": "[ActivityLogAlertLeafCondition]"}, } - def __init__(self, *, all_of: List["_models.ActivityLogAlertLeafCondition"], **kwargs): + def __init__(self, *, all_of: List["_models.ActivityLogAlertLeafCondition"], **kwargs: Any) -> None: """ :keyword all_of: The list of activity log alert conditions. Required. :paramtype all_of: @@ -354,7 +362,7 @@ class ActivityLogAlertLeafCondition(_serialization.Model): "equals": {"key": "equals", "type": "str"}, } - def __init__(self, *, field: str, equals: str, **kwargs): + def __init__(self, *, field: str, equals: str, **kwargs: Any) -> None: """ :keyword field: The name of the field that this condition will examine. The possible values for this field are (case-insensitive): 'resourceId', 'category', 'caller', 'level', @@ -389,8 +397,8 @@ def __init__( *, value: Optional[List["_models.ActivityLogAlertResource"]] = None, next_link: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword value: The list of activity log alerts. :paramtype value: list[~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertResource] @@ -417,7 +425,7 @@ class ActivityLogAlertPatchBody(_serialization.Model): "enabled": {"key": "properties.enabled", "type": "bool"}, } - def __init__(self, *, tags: Optional[Dict[str, str]] = None, enabled: bool = True, **kwargs): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, enabled: bool = True, **kwargs: Any) -> None: """ :keyword tags: Resource tags. :paramtype tags: dict[str, str] @@ -492,8 +500,8 @@ def __init__( condition: Optional["_models.ActivityLogAlertAllOfCondition"] = None, actions: Optional["_models.ActivityLogAlertActionList"] = None, description: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword location: Resource location. Required. :paramtype location: str @@ -567,8 +575,8 @@ def __init__( is_global_runbook: bool, name: Optional[str] = None, service_uri: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword automation_account_id: The Azure automation account Id which holds this runbook and authenticate to Azure resource. Required. @@ -615,7 +623,7 @@ class AzureAppPushReceiver(_serialization.Model): "email_address": {"key": "emailAddress", "type": "str"}, } - def __init__(self, *, name: str, email_address: str, **kwargs): + def __init__(self, *, name: str, email_address: str, **kwargs: Any) -> None: """ :keyword name: The name of the Azure mobile app push receiver. Names must be unique across all receivers within an action group. Required. @@ -657,7 +665,7 @@ class EmailReceiver(_serialization.Model): "status": {"key": "status", "type": "str"}, } - def __init__(self, *, name: str, email_address: str, **kwargs): + def __init__(self, *, name: str, email_address: str, **kwargs: Any) -> None: """ :keyword name: The name of the email receiver. Names must be unique across all receivers within an action group. Required. @@ -688,7 +696,7 @@ class EnableRequest(_serialization.Model): "receiver_name": {"key": "receiverName", "type": "str"}, } - def __init__(self, *, receiver_name: str, **kwargs): + def __init__(self, *, receiver_name: str, **kwargs: Any) -> None: """ :keyword receiver_name: The name of the receiver to resubscribe. Required. :paramtype receiver_name: str @@ -711,7 +719,7 @@ class ErrorResponse(_serialization.Model): "message": {"key": "message", "type": "str"}, } - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: """ :keyword code: Error code. :paramtype code: str @@ -762,8 +770,8 @@ class ItsmReceiver(_serialization.Model): } def __init__( - self, *, name: str, workspace_id: str, connection_id: str, ticket_configuration: str, region: str, **kwargs - ): + self, *, name: str, workspace_id: str, connection_id: str, ticket_configuration: str, region: str, **kwargs: Any + ) -> None: """ :keyword name: The name of the Itsm receiver. Names must be unique across all receivers within an action group. Required. @@ -822,7 +830,7 @@ class SmsReceiver(_serialization.Model): "status": {"key": "status", "type": "str"}, } - def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs): + def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs: Any) -> None: """ :keyword name: The name of the SMS receiver. Names must be unique across all receivers within an action group. Required. @@ -861,7 +869,7 @@ class WebhookReceiver(_serialization.Model): "service_uri": {"key": "serviceUri", "type": "str"}, } - def __init__(self, *, name: str, service_uri: str, **kwargs): + def __init__(self, *, name: str, service_uri: str, **kwargs: Any) -> None: """ :keyword name: The name of the webhook receiver. Names must be unique across all receivers within an action group. Required. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/operations/__init__.py index 6e24b5fe0a02..204d3d1aa9c7 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/operations/__init__.py @@ -10,7 +10,7 @@ from ._activity_log_alerts_operations import ActivityLogAlertsOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/operations/_action_groups_operations.py index e7a8f40a9c36..13b906446cb0 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/operations/_action_groups_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/operations/_action_groups_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -42,8 +47,8 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -59,7 +64,7 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -78,7 +83,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -94,7 +99,7 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -111,7 +116,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -127,7 +132,7 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -144,8 +149,8 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -161,7 +166,7 @@ def build_update_request( "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -178,7 +183,7 @@ def build_list_by_subscription_id_request(subscription_id: str, **kwargs: Any) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -187,7 +192,7 @@ def build_list_by_subscription_id_request(subscription_id: str, **kwargs: Any) - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -202,7 +207,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -217,7 +222,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -234,8 +239,8 @@ def build_enable_receiver_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -251,7 +256,7 @@ def build_enable_receiver_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -354,8 +359,8 @@ def create_or_update( :type resource_group_name: str :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group: The action group to create or use for the update. Is either a model type - or a IO type. Required. + :param action_group: The action group to create or use for the update. Is either a + ActionGroupResource type or a IO type. Required. :type action_group: ~$(python-base-namespace).v2017_04_01.models.ActionGroupResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -376,9 +381,9 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -401,9 +406,9 @@ def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -421,11 +426,13 @@ def create_or_update( deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" + } @distributed_trace def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) -> _models.ActionGroupResource: @@ -452,8 +459,8 @@ def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) - _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -465,9 +472,9 @@ def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) - params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -485,7 +492,9 @@ def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) - return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -514,8 +523,8 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -527,9 +536,9 @@ def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -543,7 +552,9 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" + } @overload def update( @@ -616,8 +627,8 @@ def update( :type resource_group_name: str :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Is either a model type or a IO - type. Required. + :param action_group_patch: Parameters supplied to the operation. Is either a + ActionGroupPatchBody type or a IO type. Required. :type action_group_patch: ~$(python-base-namespace).v2017_04_01.models.ActionGroupPatchBody or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -639,9 +650,9 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -664,9 +675,9 @@ def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -684,7 +695,9 @@ def update( return deserialized - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" + } @distributed_trace def list_by_subscription_id(self, **kwargs: Any) -> Iterable["_models.ActionGroupResource"]: @@ -699,8 +712,8 @@ def list_by_subscription_id(self, **kwargs: Any) -> Iterable["_models.ActionGrou _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -721,16 +734,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -738,13 +758,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ActionGroupList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -758,7 +778,9 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_subscription_id.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups"} # type: ignore + list_by_subscription_id.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups" + } @distributed_trace def list_by_resource_group( @@ -778,8 +800,8 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -801,16 +823,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -818,13 +847,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ActionGroupList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -838,7 +867,9 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups" + } @overload def enable_receiver( # pylint: disable=inconsistent-return-statements @@ -914,7 +945,7 @@ def enable_receiver( # pylint: disable=inconsistent-return-statements :type resource_group_name: str :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param enable_request: The receiver to re-enable. Is either a model type or a IO type. + :param enable_request: The receiver to re-enable. Is either a EnableRequest type or a IO type. Required. :type enable_request: ~$(python-base-namespace).v2017_04_01.models.EnableRequest or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -936,9 +967,9 @@ def enable_receiver( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -961,9 +992,9 @@ def enable_receiver( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -977,4 +1008,6 @@ def enable_receiver( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - enable_receiver.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe"} # type: ignore + enable_receiver.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/operations/_activity_log_alerts_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/operations/_activity_log_alerts_operations.py index bd5c905f8110..8a51b786c373 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/operations/_activity_log_alerts_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/operations/_activity_log_alerts_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -42,8 +47,8 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -59,7 +64,7 @@ def build_create_or_update_request( "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -78,7 +83,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -94,7 +99,7 @@ def build_get_request( "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -111,7 +116,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -127,7 +132,7 @@ def build_delete_request( "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -144,8 +149,8 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -161,7 +166,7 @@ def build_update_request( "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -178,7 +183,7 @@ def build_list_by_subscription_id_request(subscription_id: str, **kwargs: Any) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -187,7 +192,7 @@ def build_list_by_subscription_id_request(subscription_id: str, **kwargs: Any) - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -202,7 +207,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -217,7 +222,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -319,7 +324,7 @@ def create_or_update( :param activity_log_alert_name: The name of the activity log alert. Required. :type activity_log_alert_name: str :param activity_log_alert: The activity log alert to create or use for the update. Is either a - model type or a IO type. Required. + ActivityLogAlertResource type or a IO type. Required. :type activity_log_alert: ~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -341,9 +346,9 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActivityLogAlertResource] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ActivityLogAlertResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -366,9 +371,9 @@ def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -386,11 +391,13 @@ def create_or_update( deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}" + } @distributed_trace def get( @@ -419,8 +426,8 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActivityLogAlertResource] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.ActivityLogAlertResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -432,9 +439,9 @@ def get( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -452,7 +459,9 @@ def get( return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -481,8 +490,8 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -494,9 +503,9 @@ def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -510,7 +519,9 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}" + } @overload def update( @@ -587,8 +598,8 @@ def update( :type resource_group_name: str :param activity_log_alert_name: The name of the activity log alert. Required. :type activity_log_alert_name: str - :param activity_log_alert_patch: Parameters supplied to the operation. Is either a model type - or a IO type. Required. + :param activity_log_alert_patch: Parameters supplied to the operation. Is either a + ActivityLogAlertPatchBody type or a IO type. Required. :type activity_log_alert_patch: ~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertPatchBody or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -610,9 +621,9 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActivityLogAlertResource] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ActivityLogAlertResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -635,9 +646,9 @@ def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -655,7 +666,9 @@ def update( return deserialized - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}" + } @distributed_trace def list_by_subscription_id(self, **kwargs: Any) -> Iterable["_models.ActivityLogAlertResource"]: @@ -671,8 +684,8 @@ def list_by_subscription_id(self, **kwargs: Any) -> Iterable["_models.ActivityLo _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActivityLogAlertList] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.ActivityLogAlertList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -693,16 +706,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -710,13 +730,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ActivityLogAlertList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -730,7 +750,9 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_subscription_id.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/activityLogAlerts"} # type: ignore + list_by_subscription_id.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/activityLogAlerts" + } @distributed_trace def list_by_resource_group( @@ -751,8 +773,8 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActivityLogAlertList] + api_version: Literal["2017-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) + cls: ClsType[_models.ActivityLogAlertList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -774,16 +796,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -791,13 +820,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ActivityLogAlertList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -811,4 +840,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/__init__.py index 8ba4823444a9..2c7733bfd566 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/__init__.py @@ -13,12 +13,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["MonitorManagementClient"] +__all__ = [ + "MonitorManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_configuration.py index 878fafd77a97..e68c824c7a36 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -36,7 +42,7 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2017-05-01-preview") # type: str + api_version: Literal["2017-05-01-preview"] = kwargs.pop("api_version", "2017-05-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -50,10 +56,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, **kwargs # type: Any - ): - # type: (...) -> None + def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_metadata.json index 91b170de63e4..98a13f9d0362 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_metadata.json @@ -19,13 +19,15 @@ "signature": "credential: \"TokenCredential\",", "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true + "required": true, + "method_location": "positional" }, "subscription_id": { "signature": "subscription_id: str,", "description": "The ID of the target subscription. Required.", "docstring_type": "str", - "required": true + "required": true, + "method_location": "positional" } }, "async": { @@ -48,22 +50,25 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "signature": "api_version: Optional[str]=None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } }, "async": { @@ -71,19 +76,22 @@ "signature": "api_version: Optional[str] = None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { "signature": "profile: KnownProfiles = KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } } } @@ -103,4 +111,4 @@ "metrics": "MetricsOperations", "subscription_diagnostic_settings": "SubscriptionDiagnosticSettingsOperations" } -} \ No newline at end of file +} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_monitor_management_client.py index 8fab54b78b41..c821ea432888 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_monitor_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from . import models +from . import models as _models from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ( @@ -68,7 +68,7 @@ def __init__( ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -108,15 +108,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> MonitorManagementClient + def __enter__(self) -> "MonitorManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_vendor.py index 9aad73fc743e..bd0df84f5319 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_vendor.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_vendor.py @@ -5,6 +5,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import List, cast + from azure.core.pipeline.transport import HttpRequest @@ -22,6 +24,7 @@ def _format_url_section(template, **kwargs): try: return template.format(**kwargs) except KeyError as key: - formatted_components = template.split("/") + # Need the cast, as for some reasons "split" is typed as list[str | Any] + formatted_components = cast(List[str], template.split("/")) components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_version.py index ce9ac7ae37b3..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/__init__.py index 8638dc69d869..2c151bb41c19 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/__init__.py @@ -10,12 +10,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["MonitorManagementClient"] +__all__ = [ + "MonitorManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/_configuration.py index 1af7a1025c5c..b85932e74533 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -36,7 +42,7 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2017-05-01-preview") # type: str + api_version: Literal["2017-05-01-preview"] = kwargs.pop("api_version", "2017-05-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/_monitor_management_client.py index 88cce542c171..2627c0a506a0 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/_monitor_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from .. import models +from .. import models as _models from ..._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ( @@ -68,7 +68,7 @@ def __init__( ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -115,5 +115,5 @@ async def __aenter__(self) -> "MonitorManagementClient": await self._client.__aenter__() return self - async def __aexit__(self, *exc_details) -> None: + async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/__init__.py index 17173bb65e2d..ce13a3cecdd5 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/__init__.py @@ -13,7 +13,7 @@ from ._subscription_diagnostic_settings_operations import SubscriptionDiagnosticSettingsOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_diagnostic_settings_category_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_diagnostic_settings_category_operations.py index 12e9d41fd085..a79377922645 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_diagnostic_settings_category_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_diagnostic_settings_category_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -27,6 +28,10 @@ from ..._vendor import _convert_request from ...operations._diagnostic_settings_category_operations import build_get_request, build_list_request +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -74,8 +79,10 @@ async def get(self, resource_uri: str, name: str, **kwargs: Any) -> _models.Diag _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticSettingsCategoryResource] + api_version: Literal["2017-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-05-01-preview") + ) + cls: ClsType[_models.DiagnosticSettingsCategoryResource] = kwargs.pop("cls", None) request = build_get_request( resource_uri=resource_uri, @@ -86,9 +93,9 @@ async def get(self, resource_uri: str, name: str, **kwargs: Any) -> _models.Diag params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -106,7 +113,7 @@ async def get(self, resource_uri: str, name: str, **kwargs: Any) -> _models.Diag return deserialized - get.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories/{name}"} # type: ignore + get.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories/{name}"} @distributed_trace_async async def list(self, resource_uri: str, **kwargs: Any) -> _models.DiagnosticSettingsCategoryResourceCollection: @@ -131,8 +138,10 @@ async def list(self, resource_uri: str, **kwargs: Any) -> _models.DiagnosticSett _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticSettingsCategoryResourceCollection] + api_version: Literal["2017-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-05-01-preview") + ) + cls: ClsType[_models.DiagnosticSettingsCategoryResourceCollection] = kwargs.pop("cls", None) request = build_list_request( resource_uri=resource_uri, @@ -142,9 +151,9 @@ async def list(self, resource_uri: str, **kwargs: Any) -> _models.DiagnosticSett params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -162,4 +171,4 @@ async def list(self, resource_uri: str, **kwargs: Any) -> _models.DiagnosticSett return deserialized - list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories"} # type: ignore + list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_diagnostic_settings_operations.py index 68371784d77a..391d631effaa 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_diagnostic_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_diagnostic_settings_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -32,6 +33,10 @@ build_list_request, ) +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -79,8 +84,10 @@ async def get(self, resource_uri: str, name: str, **kwargs: Any) -> _models.Diag _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticSettingsResource] + api_version: Literal["2017-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-05-01-preview") + ) + cls: ClsType[_models.DiagnosticSettingsResource] = kwargs.pop("cls", None) request = build_get_request( resource_uri=resource_uri, @@ -91,9 +98,9 @@ async def get(self, resource_uri: str, name: str, **kwargs: Any) -> _models.Diag params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -111,7 +118,7 @@ async def get(self, resource_uri: str, name: str, **kwargs: Any) -> _models.Diag return deserialized - get.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore + get.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} @overload async def create_or_update( @@ -172,8 +179,8 @@ async def create_or_update( :type resource_uri: str :param name: The name of the diagnostic setting. Required. :type name: str - :param parameters: Parameters supplied to the operation. Is either a model type or a IO type. - Required. + :param parameters: Parameters supplied to the operation. Is either a DiagnosticSettingsResource + type or a IO type. Required. :type parameters: ~$(python-base-namespace).v2017_05_01_preview.models.DiagnosticSettingsResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -195,9 +202,11 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticSettingsResource] + api_version: Literal["2017-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DiagnosticSettingsResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -219,9 +228,9 @@ async def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -239,7 +248,7 @@ async def create_or_update( return deserialized - create_or_update.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore + create_or_update.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -267,8 +276,10 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2017-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-05-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_uri=resource_uri, @@ -279,9 +290,9 @@ async def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -295,7 +306,7 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore + delete.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} @distributed_trace_async async def list(self, resource_uri: str, **kwargs: Any) -> _models.DiagnosticSettingsResourceCollection: @@ -320,8 +331,10 @@ async def list(self, resource_uri: str, **kwargs: Any) -> _models.DiagnosticSett _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticSettingsResourceCollection] + api_version: Literal["2017-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-05-01-preview") + ) + cls: ClsType[_models.DiagnosticSettingsResourceCollection] = kwargs.pop("cls", None) request = build_list_request( resource_uri=resource_uri, @@ -331,9 +344,9 @@ async def list(self, resource_uri: str, **kwargs: Any) -> _models.DiagnosticSett params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -351,4 +364,4 @@ async def list(self, resource_uri: str, **kwargs: Any) -> _models.DiagnosticSett return deserialized - list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings"} # type: ignore + list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_metric_definitions_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_metric_definitions_operations.py index ed9da3d3a328..083f7c6bdb22 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_metric_definitions_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_metric_definitions_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -29,6 +30,10 @@ from ..._vendor import _convert_request from ...operations._metric_definitions_operations import build_list_request +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -67,8 +72,10 @@ def list(self, resource_uri: str, **kwargs: Any) -> AsyncIterable["_models.Metri _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricDefinitionCollection] + api_version: Literal["2017-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-05-01-preview") + ) + cls: ClsType[_models.MetricDefinitionCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -89,16 +96,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -106,13 +120,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("MetricDefinitionCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -126,4 +140,4 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/metricDefinitions"} # type: ignore + list.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/metricDefinitions"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_metrics_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_metrics_operations.py index 9d63b97b856d..903c548693fd 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_metrics_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_metrics_operations.py @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime +import sys from typing import Any, Callable, Dict, Optional, TypeVar, Union from azure.core.exceptions import ( @@ -28,6 +29,10 @@ from ..._vendor import _convert_request from ...operations._metrics_operations import build_list_request +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -117,8 +122,10 @@ async def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.Response] + api_version: Literal["2017-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-05-01-preview") + ) + cls: ClsType[_models.Response] = kwargs.pop("cls", None) request = build_list_request( resource_uri=resource_uri, @@ -136,9 +143,9 @@ async def list( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -156,4 +163,4 @@ async def list( return deserialized - list.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/metrics"} # type: ignore + list.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/metrics"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_subscription_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_subscription_diagnostic_settings_operations.py index 9a565884bc9c..da13d9c5cbe3 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_subscription_diagnostic_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_subscription_diagnostic_settings_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -32,6 +33,10 @@ build_list_request, ) +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -78,8 +83,10 @@ async def get(self, name: str, **kwargs: Any) -> _models.SubscriptionDiagnosticS _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionDiagnosticSettingsResource] + api_version: Literal["2017-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-05-01-preview") + ) + cls: ClsType[_models.SubscriptionDiagnosticSettingsResource] = kwargs.pop("cls", None) request = build_get_request( name=name, @@ -90,9 +97,9 @@ async def get(self, name: str, **kwargs: Any) -> _models.SubscriptionDiagnosticS params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -110,7 +117,7 @@ async def get(self, name: str, **kwargs: Any) -> _models.SubscriptionDiagnosticS return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}"} @overload async def create_or_update( @@ -166,8 +173,8 @@ async def create_or_update( :param name: The name of the diagnostic setting. Required. :type name: str - :param parameters: Parameters supplied to the operation. Is either a model type or a IO type. - Required. + :param parameters: Parameters supplied to the operation. Is either a + SubscriptionDiagnosticSettingsResource type or a IO type. Required. :type parameters: ~$(python-base-namespace).v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResource or IO @@ -191,9 +198,11 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionDiagnosticSettingsResource] + api_version: Literal["2017-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SubscriptionDiagnosticSettingsResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -215,9 +224,9 @@ async def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -235,7 +244,9 @@ async def create_or_update( return deserialized - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}" + } @distributed_trace_async async def delete(self, name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements @@ -259,8 +270,10 @@ async def delete(self, name: str, **kwargs: Any) -> None: # pylint: disable=inc _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2017-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-05-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( name=name, @@ -271,9 +284,9 @@ async def delete(self, name: str, **kwargs: Any) -> None: # pylint: disable=inc params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -287,7 +300,7 @@ async def delete(self, name: str, **kwargs: Any) -> None: # pylint: disable=inc if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}"} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}"} @distributed_trace_async async def list(self, **kwargs: Any) -> _models.SubscriptionDiagnosticSettingsResourceCollection: @@ -310,8 +323,10 @@ async def list(self, **kwargs: Any) -> _models.SubscriptionDiagnosticSettingsRes _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionDiagnosticSettingsResourceCollection] + api_version: Literal["2017-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-05-01-preview") + ) + cls: ClsType[_models.SubscriptionDiagnosticSettingsResourceCollection] = kwargs.pop("cls", None) request = build_list_request( subscription_id=self._config.subscription_id, @@ -321,9 +336,9 @@ async def list(self, **kwargs: Any) -> _models.SubscriptionDiagnosticSettingsRes params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -341,4 +356,4 @@ async def list(self, **kwargs: Any) -> _models.SubscriptionDiagnosticSettingsRes return deserialized - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/__init__.py index 2dac6e181440..b0c0eda56278 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/__init__.py @@ -34,7 +34,7 @@ from ._monitor_management_client_enums import ResultType from ._monitor_management_client_enums import Unit from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/_models_py3.py index b88a92982851..f52522f0e1d2 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/_models_py3.py @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- import datetime -from typing import List, Optional, TYPE_CHECKING, Union +from typing import Any, List, Optional, TYPE_CHECKING, Union from ... import _serialization @@ -42,7 +42,7 @@ class ProxyOnlyResource(_serialization.Model): "type": {"key": "type", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.id = None @@ -80,7 +80,7 @@ class DiagnosticSettingsCategoryResource(ProxyOnlyResource): "category_type": {"key": "properties.categoryType", "type": "str"}, } - def __init__(self, *, category_type: Optional[Union[str, "_models.CategoryType"]] = None, **kwargs): + def __init__(self, *, category_type: Optional[Union[str, "_models.CategoryType"]] = None, **kwargs: Any) -> None: """ :keyword category_type: The type of the diagnostic settings category. Known values are: "Metrics" and "Logs". @@ -103,7 +103,9 @@ class DiagnosticSettingsCategoryResourceCollection(_serialization.Model): "value": {"key": "value", "type": "[DiagnosticSettingsCategoryResource]"}, } - def __init__(self, *, value: Optional[List["_models.DiagnosticSettingsCategoryResource"]] = None, **kwargs): + def __init__( + self, *, value: Optional[List["_models.DiagnosticSettingsCategoryResource"]] = None, **kwargs: Any + ) -> None: """ :keyword value: The collection of diagnostic settings category resources. :paramtype value: @@ -181,8 +183,8 @@ def __init__( logs: Optional[List["_models.LogSettings"]] = None, workspace_id: Optional[str] = None, log_analytics_destination_type: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword storage_account_id: The resource ID of the storage account to which you would like to send Diagnostic Logs. @@ -232,7 +234,7 @@ class DiagnosticSettingsResourceCollection(_serialization.Model): "value": {"key": "value", "type": "[DiagnosticSettingsResource]"}, } - def __init__(self, *, value: Optional[List["_models.DiagnosticSettingsResource"]] = None, **kwargs): + def __init__(self, *, value: Optional[List["_models.DiagnosticSettingsResource"]] = None, **kwargs: Any) -> None: """ :keyword value: The collection of diagnostic settings resources;. :paramtype value: @@ -256,7 +258,7 @@ class ErrorResponse(_serialization.Model): "message": {"key": "message", "type": "str"}, } - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: """ :keyword code: Error code. :paramtype code: str @@ -288,7 +290,7 @@ class LocalizableString(_serialization.Model): "localized_value": {"key": "localizedValue", "type": "str"}, } - def __init__(self, *, value: str, localized_value: Optional[str] = None, **kwargs): + def __init__(self, *, value: str, localized_value: Optional[str] = None, **kwargs: Any) -> None: """ :keyword value: the invariant value. Required. :paramtype value: str @@ -331,8 +333,8 @@ def __init__( enabled: bool, category: Optional[str] = None, retention_policy: Optional["_models.RetentionPolicy"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword category: Name of a Diagnostic Log category for a resource type this setting is applied to. To obtain the list of Diagnostic Log categories for a resource, first perform a GET @@ -364,7 +366,9 @@ class MetadataValue(_serialization.Model): "value": {"key": "value", "type": "str"}, } - def __init__(self, *, name: Optional["_models.LocalizableString"] = None, value: Optional[str] = None, **kwargs): + def __init__( + self, *, name: Optional["_models.LocalizableString"] = None, value: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword name: the name of the metadata. :paramtype name: ~$(python-base-namespace).v2017_05_01_preview.models.LocalizableString @@ -433,8 +437,8 @@ def __init__( display_description: Optional[str] = None, error_code: Optional[str] = None, error_message: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword id: the metric Id. Required. :paramtype id: str @@ -469,7 +473,8 @@ def __init__( class MetricAvailability(_serialization.Model): - """Metric availability specifies the time grain (aggregation interval or frequency) and the retention period for that time grain. + """Metric availability specifies the time grain (aggregation interval or frequency) and the + retention period for that time grain. :ivar time_grain: the time grain specifies the aggregation interval for the metric. Expressed as a duration 'PT1M', 'P1D', etc. @@ -489,8 +494,8 @@ def __init__( *, time_grain: Optional[datetime.timedelta] = None, retention: Optional[datetime.timedelta] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword time_grain: the time grain specifies the aggregation interval for the metric. Expressed as a duration 'PT1M', 'P1D', etc. @@ -564,8 +569,8 @@ def __init__( metric_availabilities: Optional[List["_models.MetricAvailability"]] = None, id: Optional[str] = None, # pylint: disable=redefined-builtin dimensions: Optional[List["_models.LocalizableString"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword is_dimension_required: Flag to indicate whether the dimension is required. :paramtype is_dimension_required: bool @@ -627,7 +632,7 @@ class MetricDefinitionCollection(_serialization.Model): "value": {"key": "value", "type": "[MetricDefinition]"}, } - def __init__(self, *, value: List["_models.MetricDefinition"], **kwargs): + def __init__(self, *, value: List["_models.MetricDefinition"], **kwargs: Any) -> None: """ :keyword value: the values for the metric definitions. Required. :paramtype value: list[~$(python-base-namespace).v2017_05_01_preview.models.MetricDefinition] @@ -671,8 +676,8 @@ def __init__( time_grain: Optional[datetime.timedelta] = None, category: Optional[str] = None, retention_policy: Optional["_models.RetentionPolicy"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword time_grain: the timegrain of the metric in ISO8601 format. :paramtype time_grain: ~datetime.timedelta @@ -735,8 +740,8 @@ def __init__( maximum: Optional[float] = None, total: Optional[float] = None, count: Optional[int] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword time_stamp: the timestamp for the metric value in ISO 8601 format. Required. :paramtype time_stamp: ~datetime.datetime @@ -800,8 +805,8 @@ def __init__( value: List["_models.Metric"], cost: Optional[int] = None, interval: Optional[datetime.timedelta] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword cost: The integer value representing the relative cost of the query. :paramtype cost: int @@ -845,7 +850,7 @@ class RetentionPolicy(_serialization.Model): "days": {"key": "days", "type": "int"}, } - def __init__(self, *, enabled: bool, days: int, **kwargs): + def __init__(self, *, enabled: bool, days: int, **kwargs: Any) -> None: """ :keyword enabled: a value indicating whether the retention policy is enabled. Required. :paramtype enabled: bool @@ -886,7 +891,7 @@ class SubscriptionProxyOnlyResource(_serialization.Model): "location": {"key": "location", "type": "str"}, } - def __init__(self, *, location: Optional[str] = None, **kwargs): + def __init__(self, *, location: Optional[str] = None, **kwargs: Any) -> None: """ :keyword location: Location of the resource. :paramtype location: str @@ -960,8 +965,8 @@ def __init__( event_hub_name: Optional[str] = None, logs: Optional[List["_models.SubscriptionLogSettings"]] = None, workspace_id: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword location: Location of the resource. :paramtype location: str @@ -1005,7 +1010,9 @@ class SubscriptionDiagnosticSettingsResourceCollection(_serialization.Model): "value": {"key": "value", "type": "[SubscriptionDiagnosticSettingsResource]"}, } - def __init__(self, *, value: Optional[List["_models.SubscriptionDiagnosticSettingsResource"]] = None, **kwargs): + def __init__( + self, *, value: Optional[List["_models.SubscriptionDiagnosticSettingsResource"]] = None, **kwargs: Any + ) -> None: """ :keyword value: The collection of subscription diagnostic settings resources. :paramtype value: @@ -1036,7 +1043,7 @@ class SubscriptionLogSettings(_serialization.Model): "enabled": {"key": "enabled", "type": "bool"}, } - def __init__(self, *, enabled: bool, category: Optional[str] = None, **kwargs): + def __init__(self, *, enabled: bool, category: Optional[str] = None, **kwargs: Any) -> None: """ :keyword category: Name of a Subscription Diagnostic Log category for a resource type this setting is applied to. @@ -1070,8 +1077,8 @@ def __init__( *, metadatavalues: Optional[List["_models.MetadataValue"]] = None, data: Optional[List["_models.MetricValue"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword metadatavalues: the metadata values returned if $filter was specified in the call. :paramtype metadatavalues: diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/__init__.py index 17173bb65e2d..ce13a3cecdd5 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/__init__.py @@ -13,7 +13,7 @@ from ._subscription_diagnostic_settings_operations import SubscriptionDiagnosticSettingsOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_diagnostic_settings_category_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_diagnostic_settings_category_operations.py index c552b51e8228..7f47aa9c1bf4 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_diagnostic_settings_category_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_diagnostic_settings_category_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -27,6 +28,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -38,7 +43,9 @@ def build_get_request(resource_uri: str, name: str, **kwargs: Any) -> HttpReques _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str + api_version: Literal["2017-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-05-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -48,7 +55,7 @@ def build_get_request(resource_uri: str, name: str, **kwargs: Any) -> HttpReques "name": _SERIALIZER.url("name", name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -63,7 +70,9 @@ 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 = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str + api_version: Literal["2017-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-05-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -72,7 +81,7 @@ def build_list_request(resource_uri: str, **kwargs: Any) -> HttpRequest: "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -126,8 +135,10 @@ def get(self, resource_uri: str, name: str, **kwargs: Any) -> _models.Diagnostic _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticSettingsCategoryResource] + api_version: Literal["2017-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-05-01-preview") + ) + cls: ClsType[_models.DiagnosticSettingsCategoryResource] = kwargs.pop("cls", None) request = build_get_request( resource_uri=resource_uri, @@ -138,9 +149,9 @@ def get(self, resource_uri: str, name: str, **kwargs: Any) -> _models.Diagnostic params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -158,7 +169,7 @@ def get(self, resource_uri: str, name: str, **kwargs: Any) -> _models.Diagnostic return deserialized - get.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories/{name}"} # type: ignore + get.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories/{name}"} @distributed_trace def list(self, resource_uri: str, **kwargs: Any) -> _models.DiagnosticSettingsCategoryResourceCollection: @@ -183,8 +194,10 @@ def list(self, resource_uri: str, **kwargs: Any) -> _models.DiagnosticSettingsCa _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticSettingsCategoryResourceCollection] + api_version: Literal["2017-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-05-01-preview") + ) + cls: ClsType[_models.DiagnosticSettingsCategoryResourceCollection] = kwargs.pop("cls", None) request = build_list_request( resource_uri=resource_uri, @@ -194,9 +207,9 @@ def list(self, resource_uri: str, **kwargs: Any) -> _models.DiagnosticSettingsCa params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -214,4 +227,4 @@ def list(self, resource_uri: str, **kwargs: Any) -> _models.DiagnosticSettingsCa return deserialized - list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories"} # type: ignore + list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_diagnostic_settings_operations.py index 7dc09a91c1a2..da297f165902 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_diagnostic_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_diagnostic_settings_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -27,6 +28,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -38,7 +43,9 @@ def build_get_request(resource_uri: str, name: str, **kwargs: Any) -> HttpReques _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str + api_version: Literal["2017-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-05-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -48,7 +55,7 @@ def build_get_request(resource_uri: str, name: str, **kwargs: Any) -> HttpReques "name": _SERIALIZER.url("name", name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -63,8 +70,10 @@ def build_create_or_update_request(resource_uri: str, name: str, **kwargs: Any) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2017-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -74,7 +83,7 @@ def build_create_or_update_request(resource_uri: str, name: str, **kwargs: Any) "name": _SERIALIZER.url("name", name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -91,7 +100,9 @@ def build_delete_request(resource_uri: str, name: str, **kwargs: Any) -> HttpReq _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str + api_version: Literal["2017-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-05-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -101,7 +112,7 @@ def build_delete_request(resource_uri: str, name: str, **kwargs: Any) -> HttpReq "name": _SERIALIZER.url("name", name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -116,7 +127,9 @@ 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 = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str + api_version: Literal["2017-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-05-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -125,7 +138,7 @@ def build_list_request(resource_uri: str, **kwargs: Any) -> HttpRequest: "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -179,8 +192,10 @@ def get(self, resource_uri: str, name: str, **kwargs: Any) -> _models.Diagnostic _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticSettingsResource] + api_version: Literal["2017-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-05-01-preview") + ) + cls: ClsType[_models.DiagnosticSettingsResource] = kwargs.pop("cls", None) request = build_get_request( resource_uri=resource_uri, @@ -191,9 +206,9 @@ def get(self, resource_uri: str, name: str, **kwargs: Any) -> _models.Diagnostic params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -211,7 +226,7 @@ def get(self, resource_uri: str, name: str, **kwargs: Any) -> _models.Diagnostic return deserialized - get.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore + get.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} @overload def create_or_update( @@ -272,8 +287,8 @@ def create_or_update( :type resource_uri: str :param name: The name of the diagnostic setting. Required. :type name: str - :param parameters: Parameters supplied to the operation. Is either a model type or a IO type. - Required. + :param parameters: Parameters supplied to the operation. Is either a DiagnosticSettingsResource + type or a IO type. Required. :type parameters: ~$(python-base-namespace).v2017_05_01_preview.models.DiagnosticSettingsResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -295,9 +310,11 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticSettingsResource] + api_version: Literal["2017-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DiagnosticSettingsResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -319,9 +336,9 @@ def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -339,7 +356,7 @@ def create_or_update( return deserialized - create_or_update.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore + create_or_update.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -367,8 +384,10 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2017-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-05-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_uri=resource_uri, @@ -379,9 +398,9 @@ def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -395,7 +414,7 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore + delete.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} @distributed_trace def list(self, resource_uri: str, **kwargs: Any) -> _models.DiagnosticSettingsResourceCollection: @@ -420,8 +439,10 @@ def list(self, resource_uri: str, **kwargs: Any) -> _models.DiagnosticSettingsRe _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticSettingsResourceCollection] + api_version: Literal["2017-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-05-01-preview") + ) + cls: ClsType[_models.DiagnosticSettingsResourceCollection] = kwargs.pop("cls", None) request = build_list_request( resource_uri=resource_uri, @@ -431,9 +452,9 @@ def list(self, resource_uri: str, **kwargs: Any) -> _models.DiagnosticSettingsRe params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -451,4 +472,4 @@ def list(self, resource_uri: str, **kwargs: Any) -> _models.DiagnosticSettingsRe return deserialized - list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings"} # type: ignore + list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_metric_definitions_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_metric_definitions_operations.py index 344aa5005649..11dd8e2bd921 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_metric_definitions_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_metric_definitions_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,9 @@ 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 = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str + api_version: Literal["2017-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-05-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -49,7 +56,7 @@ def build_list_request(resource_uri: str, **kwargs: Any) -> HttpRequest: "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -94,8 +101,10 @@ def list(self, resource_uri: str, **kwargs: Any) -> Iterable["_models.MetricDefi _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricDefinitionCollection] + api_version: Literal["2017-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-05-01-preview") + ) + cls: ClsType[_models.MetricDefinitionCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -116,16 +125,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -133,13 +149,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("MetricDefinitionCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -153,4 +169,4 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/metricDefinitions"} # type: ignore + list.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/metricDefinitions"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_metrics_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_metrics_operations.py index f86eaf51c34c..6dd25c6e24f8 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_metrics_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_metrics_operations.py @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime +import sys from typing import Any, Callable, Dict, Optional, TypeVar, Union from azure.core.exceptions import ( @@ -28,6 +29,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -51,7 +56,9 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str + api_version: Literal["2017-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-05-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -60,7 +67,7 @@ def build_list_request( "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters if timespan is not None: @@ -172,8 +179,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.Response] + api_version: Literal["2017-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-05-01-preview") + ) + cls: ClsType[_models.Response] = kwargs.pop("cls", None) request = build_list_request( resource_uri=resource_uri, @@ -191,9 +200,9 @@ def list( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -211,4 +220,4 @@ def list( return deserialized - list.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/metrics"} # type: ignore + list.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/metrics"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_subscription_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_subscription_diagnostic_settings_operations.py index c32dfd423729..95a461ac0e7e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_subscription_diagnostic_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_subscription_diagnostic_settings_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -27,6 +28,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -38,7 +43,9 @@ def build_get_request(name: str, subscription_id: str, **kwargs: Any) -> HttpReq _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str + api_version: Literal["2017-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-05-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -50,7 +57,7 @@ def build_get_request(name: str, subscription_id: str, **kwargs: Any) -> HttpReq "name": _SERIALIZER.url("name", name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -65,8 +72,10 @@ def build_create_or_update_request(name: str, subscription_id: str, **kwargs: An _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2017-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -78,7 +87,7 @@ def build_create_or_update_request(name: str, subscription_id: str, **kwargs: An "name": _SERIALIZER.url("name", name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -95,7 +104,9 @@ def build_delete_request(name: str, subscription_id: str, **kwargs: Any) -> Http _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str + api_version: Literal["2017-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-05-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -107,7 +118,7 @@ def build_delete_request(name: str, subscription_id: str, **kwargs: Any) -> Http "name": _SERIALIZER.url("name", name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -122,7 +133,9 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str + api_version: Literal["2017-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-05-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -131,7 +144,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -184,8 +197,10 @@ def get(self, name: str, **kwargs: Any) -> _models.SubscriptionDiagnosticSetting _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionDiagnosticSettingsResource] + api_version: Literal["2017-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-05-01-preview") + ) + cls: ClsType[_models.SubscriptionDiagnosticSettingsResource] = kwargs.pop("cls", None) request = build_get_request( name=name, @@ -196,9 +211,9 @@ def get(self, name: str, **kwargs: Any) -> _models.SubscriptionDiagnosticSetting params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -216,7 +231,7 @@ def get(self, name: str, **kwargs: Any) -> _models.SubscriptionDiagnosticSetting return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}"} @overload def create_or_update( @@ -272,8 +287,8 @@ def create_or_update( :param name: The name of the diagnostic setting. Required. :type name: str - :param parameters: Parameters supplied to the operation. Is either a model type or a IO type. - Required. + :param parameters: Parameters supplied to the operation. Is either a + SubscriptionDiagnosticSettingsResource type or a IO type. Required. :type parameters: ~$(python-base-namespace).v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResource or IO @@ -297,9 +312,11 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionDiagnosticSettingsResource] + api_version: Literal["2017-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SubscriptionDiagnosticSettingsResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -321,9 +338,9 @@ def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -341,7 +358,9 @@ def create_or_update( return deserialized - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}" + } @distributed_trace def delete(self, name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements @@ -365,8 +384,10 @@ def delete(self, name: str, **kwargs: Any) -> None: # pylint: disable=inconsist _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2017-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-05-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( name=name, @@ -377,9 +398,9 @@ def delete(self, name: str, **kwargs: Any) -> None: # pylint: disable=inconsist params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -393,7 +414,7 @@ def delete(self, name: str, **kwargs: Any) -> None: # pylint: disable=inconsist if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}"} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}"} @distributed_trace def list(self, **kwargs: Any) -> _models.SubscriptionDiagnosticSettingsResourceCollection: @@ -416,8 +437,10 @@ def list(self, **kwargs: Any) -> _models.SubscriptionDiagnosticSettingsResourceC _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionDiagnosticSettingsResourceCollection] + api_version: Literal["2017-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-05-01-preview") + ) + cls: ClsType[_models.SubscriptionDiagnosticSettingsResourceCollection] = kwargs.pop("cls", None) request = build_list_request( subscription_id=self._config.subscription_id, @@ -427,9 +450,9 @@ def list(self, **kwargs: Any) -> _models.SubscriptionDiagnosticSettingsResourceC params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -447,4 +470,4 @@ def list(self, **kwargs: Any) -> _models.SubscriptionDiagnosticSettingsResourceC return deserialized - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/__init__.py index 8ba4823444a9..2c7733bfd566 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/__init__.py @@ -13,12 +13,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["MonitorManagementClient"] +__all__ = [ + "MonitorManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_configuration.py index 0298e2b7bade..a8702ad90584 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -34,7 +40,7 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2017-12-01-preview") # type: str + api_version: Literal["2017-12-01-preview"] = kwargs.pop("api_version", "2017-12-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -45,10 +51,7 @@ def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, **kwargs # type: Any - ): - # type: (...) -> None + def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_metadata.json index 08f2fd24d485..19de87bd9d48 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_metadata.json @@ -19,7 +19,8 @@ "signature": "credential: \"TokenCredential\",", "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true + "required": true, + "method_location": "positional" } }, "async": { @@ -36,22 +37,25 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "signature": "api_version: Optional[str]=None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } }, "async": { @@ -59,19 +63,22 @@ "signature": "api_version: Optional[str] = None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { "signature": "profile: KnownProfiles = KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } } } @@ -87,4 +94,4 @@ "operation_groups": { "metric_namespaces": "MetricNamespacesOperations" } -} \ No newline at end of file +} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_monitor_management_client.py index f9f22a1f9605..872c38e96560 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_monitor_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from . import models +from . import models as _models from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import MetricNamespacesOperations @@ -43,7 +43,7 @@ def __init__( self._config = MonitorManagementClientConfiguration(credential=credential, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -73,15 +73,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> MonitorManagementClient + def __enter__(self) -> "MonitorManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_vendor.py index 9aad73fc743e..bd0df84f5319 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_vendor.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_vendor.py @@ -5,6 +5,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import List, cast + from azure.core.pipeline.transport import HttpRequest @@ -22,6 +24,7 @@ def _format_url_section(template, **kwargs): try: return template.format(**kwargs) except KeyError as key: - formatted_components = template.split("/") + # Need the cast, as for some reasons "split" is typed as list[str | Any] + formatted_components = cast(List[str], template.split("/")) components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_version.py index ce9ac7ae37b3..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/__init__.py index 8638dc69d869..2c151bb41c19 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/__init__.py @@ -10,12 +10,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["MonitorManagementClient"] +__all__ = [ + "MonitorManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/_configuration.py index f1c5c1ea1f31..944ba3a22dbb 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -34,7 +40,7 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2017-12-01-preview") # type: str + api_version: Literal["2017-12-01-preview"] = kwargs.pop("api_version", "2017-12-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/_monitor_management_client.py index 547061f581bf..bab754f837ad 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/_monitor_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from .. import models +from .. import models as _models from ..._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import MetricNamespacesOperations @@ -43,7 +43,7 @@ def __init__( self._config = MonitorManagementClientConfiguration(credential=credential, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -80,5 +80,5 @@ async def __aenter__(self) -> "MonitorManagementClient": await self._client.__aenter__() return self - async def __aexit__(self, *exc_details) -> None: + async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/operations/__init__.py index 6e29688e0b33..b230e557d823 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/operations/__init__.py @@ -9,7 +9,7 @@ from ._metric_namespaces_operations import MetricNamespacesOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/operations/_metric_namespaces_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/operations/_metric_namespaces_operations.py index 43387e2b2ea1..5bcc23bd8d02 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/operations/_metric_namespaces_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/operations/_metric_namespaces_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -29,6 +30,10 @@ from ..._vendor import _convert_request from ...operations._metric_namespaces_operations import build_list_request +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -72,8 +77,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-12-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricNamespaceCollection] + api_version: Literal["2017-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-12-01-preview") + ) + cls: ClsType[_models.MetricNamespaceCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -95,16 +102,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -112,13 +126,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("MetricNamespaceCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -132,4 +146,4 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/metricNamespaces"} # type: ignore + list.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/metricNamespaces"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/__init__.py index 5794ea50a2a0..f4b8efc1b5b0 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/__init__.py @@ -13,7 +13,7 @@ from ._monitor_management_client_enums import NamespaceClassification from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/_models_py3.py index a5774788c12c..b472ccea89c7 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/_models_py3.py @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, Optional, TYPE_CHECKING, Union +from typing import Any, List, Optional, TYPE_CHECKING, Union from ... import _serialization @@ -30,7 +30,7 @@ class ErrorResponse(_serialization.Model): "message": {"key": "message", "type": "str"}, } - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: """ :keyword code: Error code. :paramtype code: str @@ -74,8 +74,8 @@ def __init__( name: Optional[str] = None, classification: Optional[Union[str, "_models.NamespaceClassification"]] = None, properties: Optional["_models.MetricNamespaceName"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword id: The ID of the metric namespace. :paramtype id: str @@ -114,7 +114,7 @@ class MetricNamespaceCollection(_serialization.Model): "value": {"key": "value", "type": "[MetricNamespace]"}, } - def __init__(self, *, value: List["_models.MetricNamespace"], **kwargs): + def __init__(self, *, value: List["_models.MetricNamespace"], **kwargs: Any) -> None: """ :keyword value: The values for the metric namespaces. Required. :paramtype value: list[~$(python-base-namespace).v2017_12_01_preview.models.MetricNamespace] @@ -134,7 +134,7 @@ class MetricNamespaceName(_serialization.Model): "metric_namespace_name": {"key": "metricNamespaceName", "type": "str"}, } - def __init__(self, *, metric_namespace_name: Optional[str] = None, **kwargs): + def __init__(self, *, metric_namespace_name: Optional[str] = None, **kwargs: Any) -> None: """ :keyword metric_namespace_name: The metric namespace name. :paramtype metric_namespace_name: str diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/operations/__init__.py index 6e29688e0b33..b230e557d823 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/operations/__init__.py @@ -9,7 +9,7 @@ from ._metric_namespaces_operations import MetricNamespacesOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/operations/_metric_namespaces_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/operations/_metric_namespaces_operations.py index 0da9fcc58f0a..3c36bda43d25 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/operations/_metric_namespaces_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/operations/_metric_namespaces_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,9 @@ def build_list_request(resource_uri: str, *, start_time: Optional[str] = None, * _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-12-01-preview")) # type: str + api_version: Literal["2017-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-12-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -49,7 +56,7 @@ def build_list_request(resource_uri: str, *, start_time: Optional[str] = None, * "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -101,8 +108,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-12-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricNamespaceCollection] + api_version: Literal["2017-12-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2017-12-01-preview") + ) + cls: ClsType[_models.MetricNamespaceCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -124,16 +133,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -141,13 +157,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("MetricNamespaceCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -161,4 +177,4 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/metricNamespaces"} # type: ignore + list.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/metricNamespaces"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/__init__.py index 8ba4823444a9..2c7733bfd566 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/__init__.py @@ -13,12 +13,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["MonitorManagementClient"] +__all__ = [ + "MonitorManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_configuration.py index 552e4bc3bdbf..a672e9dac2c3 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -34,7 +40,7 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2018-01-01") # type: str + api_version: Literal["2018-01-01"] = kwargs.pop("api_version", "2018-01-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -45,10 +51,7 @@ def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, **kwargs # type: Any - ): - # type: (...) -> None + def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_metadata.json index 554f2b254864..1079b3dba290 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_metadata.json @@ -19,7 +19,8 @@ "signature": "credential: \"TokenCredential\",", "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true + "required": true, + "method_location": "positional" } }, "async": { @@ -36,22 +37,25 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "signature": "api_version: Optional[str]=None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } }, "async": { @@ -59,19 +63,22 @@ "signature": "api_version: Optional[str] = None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { "signature": "profile: KnownProfiles = KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } } } @@ -88,4 +95,4 @@ "metric_definitions": "MetricDefinitionsOperations", "metrics": "MetricsOperations" } -} \ No newline at end of file +} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_monitor_management_client.py index e0b44c10e1bf..8f3384c899cb 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_monitor_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from . import models +from . import models as _models from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import MetricDefinitionsOperations, MetricsOperations @@ -45,7 +45,7 @@ def __init__( self._config = MonitorManagementClientConfiguration(credential=credential, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -76,15 +76,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> MonitorManagementClient + def __enter__(self) -> "MonitorManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_vendor.py index 9aad73fc743e..bd0df84f5319 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_vendor.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_vendor.py @@ -5,6 +5,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import List, cast + from azure.core.pipeline.transport import HttpRequest @@ -22,6 +24,7 @@ def _format_url_section(template, **kwargs): try: return template.format(**kwargs) except KeyError as key: - formatted_components = template.split("/") + # Need the cast, as for some reasons "split" is typed as list[str | Any] + formatted_components = cast(List[str], template.split("/")) components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_version.py index ce9ac7ae37b3..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/__init__.py index 8638dc69d869..2c151bb41c19 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/__init__.py @@ -10,12 +10,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["MonitorManagementClient"] +__all__ = [ + "MonitorManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/_configuration.py index 70b621b9c805..29b436691897 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -34,7 +40,7 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2018-01-01") # type: str + api_version: Literal["2018-01-01"] = kwargs.pop("api_version", "2018-01-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/_monitor_management_client.py index 9e6a7ac9a08a..83d66f57d622 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/_monitor_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from .. import models +from .. import models as _models from ..._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import MetricDefinitionsOperations, MetricsOperations @@ -45,7 +45,7 @@ def __init__( self._config = MonitorManagementClientConfiguration(credential=credential, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -83,5 +83,5 @@ async def __aenter__(self) -> "MonitorManagementClient": await self._client.__aenter__() return self - async def __aexit__(self, *exc_details) -> None: + async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/operations/__init__.py index adca96b9481a..d46ec2816fa2 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/operations/__init__.py @@ -10,7 +10,7 @@ from ._metrics_operations import MetricsOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/operations/_metric_definitions_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/operations/_metric_definitions_operations.py index 12fa6eb8f797..dd9410f403e2 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/operations/_metric_definitions_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/operations/_metric_definitions_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -29,6 +30,10 @@ from ..._vendor import _convert_request from ...operations._metric_definitions_operations import build_list_request +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -72,8 +77,8 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricDefinitionCollection] + api_version: Literal["2018-01-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01")) + cls: ClsType[_models.MetricDefinitionCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -95,16 +100,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -112,13 +124,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("MetricDefinitionCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -132,4 +144,4 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/metricDefinitions"} # type: ignore + list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/metricDefinitions"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/operations/_metrics_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/operations/_metrics_operations.py index b021d377fd94..9000b7762c50 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/operations/_metrics_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/operations/_metrics_operations.py @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime +import sys from typing import Any, Callable, Dict, Optional, TypeVar, Union from azure.core.exceptions import ( @@ -28,6 +29,10 @@ from ..._vendor import _convert_request from ...operations._metrics_operations import build_list_request +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -126,8 +131,8 @@ async def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.Response] + api_version: Literal["2018-01-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01")) + cls: ClsType[_models.Response] = kwargs.pop("cls", None) request = build_list_request( resource_uri=resource_uri, @@ -146,9 +151,9 @@ async def list( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -166,4 +171,4 @@ async def list( return deserialized - list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/metrics"} # type: ignore + list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/metrics"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/__init__.py index c828b61f896d..f3737db3f508 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/__init__.py @@ -22,7 +22,7 @@ from ._monitor_management_client_enums import MetricUnit from ._monitor_management_client_enums import ResultType from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/_models_py3.py index bcd3df3cbeaf..3c205263e1de 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/_models_py3.py @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- import datetime -from typing import List, Optional, TYPE_CHECKING, Union +from typing import Any, List, Optional, TYPE_CHECKING, Union from ... import _serialization @@ -31,7 +31,7 @@ class ErrorResponse(_serialization.Model): "message": {"key": "message", "type": "str"}, } - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: """ :keyword code: Error code. :paramtype code: str @@ -63,7 +63,7 @@ class LocalizableString(_serialization.Model): "localized_value": {"key": "localizedValue", "type": "str"}, } - def __init__(self, *, value: str, localized_value: Optional[str] = None, **kwargs): + def __init__(self, *, value: str, localized_value: Optional[str] = None, **kwargs: Any) -> None: """ :keyword value: the invariant value. Required. :paramtype value: str @@ -89,7 +89,9 @@ class MetadataValue(_serialization.Model): "value": {"key": "value", "type": "str"}, } - def __init__(self, *, name: Optional["_models.LocalizableString"] = None, value: Optional[str] = None, **kwargs): + def __init__( + self, *, name: Optional["_models.LocalizableString"] = None, value: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword name: the name of the metadata. :paramtype name: ~$(python-base-namespace).v2018_01_01.models.LocalizableString @@ -157,8 +159,8 @@ def __init__( display_description: Optional[str] = None, error_code: Optional[str] = None, error_message: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword id: the metric Id. Required. :paramtype id: str @@ -192,7 +194,8 @@ def __init__( class MetricAvailability(_serialization.Model): - """Metric availability specifies the time grain (aggregation interval or frequency) and the retention period for that time grain. + """Metric availability specifies the time grain (aggregation interval or frequency) and the + retention period for that time grain. :ivar time_grain: the time grain specifies the aggregation interval for the metric. Expressed as a duration 'PT1M', 'P1D', etc. @@ -212,8 +215,8 @@ def __init__( *, time_grain: Optional[datetime.timedelta] = None, retention: Optional[datetime.timedelta] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword time_grain: the time grain specifies the aggregation interval for the metric. Expressed as a duration 'PT1M', 'P1D', etc. @@ -300,8 +303,8 @@ def __init__( metric_availabilities: Optional[List["_models.MetricAvailability"]] = None, id: Optional[str] = None, # pylint: disable=redefined-builtin dimensions: Optional[List["_models.LocalizableString"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword is_dimension_required: Flag to indicate whether the dimension is required. :paramtype is_dimension_required: bool @@ -373,7 +376,7 @@ class MetricDefinitionCollection(_serialization.Model): "value": {"key": "value", "type": "[MetricDefinition]"}, } - def __init__(self, *, value: List["_models.MetricDefinition"], **kwargs): + def __init__(self, *, value: List["_models.MetricDefinition"], **kwargs: Any) -> None: """ :keyword value: the values for the metric definitions. Required. :paramtype value: list[~$(python-base-namespace).v2018_01_01.models.MetricDefinition] @@ -424,8 +427,8 @@ def __init__( maximum: Optional[float] = None, total: Optional[float] = None, count: Optional[float] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword time_stamp: the timestamp for the metric value in ISO 8601 format. Required. :paramtype time_stamp: ~datetime.datetime @@ -497,8 +500,8 @@ def __init__( interval: Optional[datetime.timedelta] = None, namespace: Optional[str] = None, resourceregion: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword cost: The integer value representing the relative cost of the query. :paramtype cost: int @@ -546,8 +549,8 @@ def __init__( *, metadatavalues: Optional[List["_models.MetadataValue"]] = None, data: Optional[List["_models.MetricValue"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword metadatavalues: the metadata values returned if $filter was specified in the call. :paramtype metadatavalues: list[~$(python-base-namespace).v2018_01_01.models.MetadataValue] diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/operations/__init__.py index adca96b9481a..d46ec2816fa2 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/operations/__init__.py @@ -10,7 +10,7 @@ from ._metrics_operations import MetricsOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/operations/_metric_definitions_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/operations/_metric_definitions_operations.py index c3dcf6fc705d..72cf1e6f50ba 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/operations/_metric_definitions_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/operations/_metric_definitions_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,7 @@ def build_list_request(resource_uri: str, *, metricnamespace: Optional[str] = No _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01")) # type: str + api_version: Literal["2018-01-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -49,7 +54,7 @@ def build_list_request(resource_uri: str, *, metricnamespace: Optional[str] = No "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -101,8 +106,8 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricDefinitionCollection] + api_version: Literal["2018-01-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01")) + cls: ClsType[_models.MetricDefinitionCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -124,16 +129,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -141,13 +153,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("MetricDefinitionCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -161,4 +173,4 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/metricDefinitions"} # type: ignore + list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/metricDefinitions"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/operations/_metrics_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/operations/_metrics_operations.py index 0458cd275b6b..82796cff753c 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/operations/_metrics_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/operations/_metrics_operations.py @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime +import sys from typing import Any, Callable, Dict, Optional, TypeVar, Union from azure.core.exceptions import ( @@ -28,6 +29,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -52,7 +57,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01")) # type: str + api_version: Literal["2018-01-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -61,7 +66,7 @@ def build_list_request( "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters if timespan is not None: @@ -184,8 +189,8 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.Response] + api_version: Literal["2018-01-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-01-01")) + cls: ClsType[_models.Response] = kwargs.pop("cls", None) request = build_list_request( resource_uri=resource_uri, @@ -204,9 +209,9 @@ def list( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -224,4 +229,4 @@ def list( return deserialized - list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/metrics"} # type: ignore + list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/metrics"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/__init__.py index 8ba4823444a9..2c7733bfd566 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/__init__.py @@ -13,12 +13,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["MonitorManagementClient"] +__all__ = [ + "MonitorManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_configuration.py index 8146f966a635..d0ee3926b584 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -36,7 +42,7 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2018-03-01") # type: str + api_version: Literal["2018-03-01"] = kwargs.pop("api_version", "2018-03-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -50,10 +56,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, **kwargs # type: Any - ): - # type: (...) -> None + def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_metadata.json index 41cb09faca9b..4460b40de763 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_metadata.json @@ -19,13 +19,15 @@ "signature": "credential: \"TokenCredential\",", "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true + "required": true, + "method_location": "positional" }, "subscription_id": { "signature": "subscription_id: str,", "description": "The ID of the target subscription. Required.", "docstring_type": "str", - "required": true + "required": true, + "method_location": "positional" } }, "async": { @@ -48,22 +50,25 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "signature": "api_version: Optional[str]=None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } }, "async": { @@ -71,19 +76,22 @@ "signature": "api_version: Optional[str] = None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { "signature": "profile: KnownProfiles = KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } } } @@ -101,4 +109,4 @@ "metric_alerts": "MetricAlertsOperations", "metric_alerts_status": "MetricAlertsStatusOperations" } -} \ No newline at end of file +} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_monitor_management_client.py index 4641d8caf631..d059d28817c1 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_monitor_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from . import models +from . import models as _models from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ActionGroupsOperations, MetricAlertsOperations, MetricAlertsStatusOperations @@ -55,7 +55,7 @@ def __init__( ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -87,15 +87,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> MonitorManagementClient + def __enter__(self) -> "MonitorManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_vendor.py index 9aad73fc743e..bd0df84f5319 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_vendor.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_vendor.py @@ -5,6 +5,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import List, cast + from azure.core.pipeline.transport import HttpRequest @@ -22,6 +24,7 @@ def _format_url_section(template, **kwargs): try: return template.format(**kwargs) except KeyError as key: - formatted_components = template.split("/") + # Need the cast, as for some reasons "split" is typed as list[str | Any] + formatted_components = cast(List[str], template.split("/")) components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_version.py index ce9ac7ae37b3..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/__init__.py index 8638dc69d869..2c151bb41c19 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/__init__.py @@ -10,12 +10,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["MonitorManagementClient"] +__all__ = [ + "MonitorManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/_configuration.py index 4544634ac52f..087b4a2041c7 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -36,7 +42,7 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2018-03-01") # type: str + api_version: Literal["2018-03-01"] = kwargs.pop("api_version", "2018-03-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/_monitor_management_client.py index be454df6d46f..a3c4b24f47ba 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/_monitor_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from .. import models +from .. import models as _models from ..._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ActionGroupsOperations, MetricAlertsOperations, MetricAlertsStatusOperations @@ -57,7 +57,7 @@ def __init__( ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -96,5 +96,5 @@ async def __aenter__(self) -> "MonitorManagementClient": await self._client.__aenter__() return self - async def __aexit__(self, *exc_details) -> None: + async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/__init__.py index 08442f934dbe..854cfe54a91d 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/__init__.py @@ -11,7 +11,7 @@ from ._metric_alerts_status_operations import MetricAlertsStatusOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/_action_groups_operations.py index 215eb14af5ec..ac45148e88c1 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/_action_groups_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/_action_groups_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -38,6 +39,10 @@ build_update_request, ) +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -132,8 +137,8 @@ async def create_or_update( :type resource_group_name: str :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group: The action group to create or use for the update. Is either a model type - or a IO type. Required. + :param action_group: The action group to create or use for the update. Is either a + ActionGroupResource type or a IO type. Required. :type action_group: ~$(python-base-namespace).v2018_03_01.models.ActionGroupResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -154,9 +159,9 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] + api_version: Literal["2018-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -179,9 +184,9 @@ async def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -199,11 +204,13 @@ async def create_or_update( deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" + } @distributed_trace_async async def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) -> _models.ActionGroupResource: @@ -230,8 +237,8 @@ async def get(self, resource_group_name: str, action_group_name: str, **kwargs: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] + api_version: Literal["2018-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -243,9 +250,9 @@ async def get(self, resource_group_name: str, action_group_name: str, **kwargs: params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -263,7 +270,9 @@ async def get(self, resource_group_name: str, action_group_name: str, **kwargs: return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -292,8 +301,8 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2018-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -305,9 +314,9 @@ async def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -321,7 +330,9 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" + } @overload async def update( @@ -394,8 +405,8 @@ async def update( :type resource_group_name: str :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Is either a model type or a IO - type. Required. + :param action_group_patch: Parameters supplied to the operation. Is either a + ActionGroupPatchBody type or a IO type. Required. :type action_group_patch: ~$(python-base-namespace).v2018_03_01.models.ActionGroupPatchBody or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -417,9 +428,9 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] + api_version: Literal["2018-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -442,9 +453,9 @@ async def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -462,7 +473,9 @@ async def update( return deserialized - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" + } @distributed_trace def list_by_subscription_id(self, **kwargs: Any) -> AsyncIterable["_models.ActionGroupResource"]: @@ -477,8 +490,8 @@ def list_by_subscription_id(self, **kwargs: Any) -> AsyncIterable["_models.Actio _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + api_version: Literal["2018-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -499,16 +512,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -516,13 +536,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ActionGroupList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -536,7 +556,9 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_subscription_id.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups"} # type: ignore + list_by_subscription_id.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups" + } @distributed_trace def list_by_resource_group( @@ -556,8 +578,8 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + api_version: Literal["2018-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -579,16 +601,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -596,13 +625,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ActionGroupList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -616,7 +645,9 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups" + } @overload async def enable_receiver( # pylint: disable=inconsistent-return-statements @@ -692,7 +723,7 @@ async def enable_receiver( # pylint: disable=inconsistent-return-statements :type resource_group_name: str :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param enable_request: The receiver to re-enable. Is either a model type or a IO type. + :param enable_request: The receiver to re-enable. Is either a EnableRequest type or a IO type. Required. :type enable_request: ~$(python-base-namespace).v2018_03_01.models.EnableRequest or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -714,9 +745,9 @@ async def enable_receiver( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2018-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -739,9 +770,9 @@ async def enable_receiver( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -755,4 +786,6 @@ async def enable_receiver( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - enable_receiver.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe"} # type: ignore + enable_receiver.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/_metric_alerts_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/_metric_alerts_operations.py index 4134d0409280..19ca262177b6 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/_metric_alerts_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/_metric_alerts_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -37,6 +38,10 @@ build_update_request, ) +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -73,8 +78,8 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.MetricAl _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricAlertResourceCollection] + api_version: Literal["2018-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + cls: ClsType[_models.MetricAlertResourceCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -95,16 +100,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -112,13 +124,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("MetricAlertResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -132,7 +144,7 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/metricAlerts"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/metricAlerts"} @distributed_trace def list_by_resource_group( @@ -152,8 +164,8 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricAlertResourceCollection] + api_version: Literal["2018-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + cls: ClsType[_models.MetricAlertResourceCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -175,16 +187,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -192,13 +211,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("MetricAlertResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -212,7 +231,9 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts" + } @distributed_trace_async async def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _models.MetricAlertResource: @@ -239,8 +260,8 @@ async def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricAlertResource] + api_version: Literal["2018-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + cls: ClsType[_models.MetricAlertResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -252,9 +273,9 @@ async def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -272,7 +293,9 @@ async def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}" + } @overload async def create_or_update( @@ -345,8 +368,8 @@ async def create_or_update( :type resource_group_name: str :param rule_name: The name of the rule. Required. :type rule_name: str - :param parameters: The parameters of the rule to create or update. Is either a model type or a - IO type. Required. + :param parameters: The parameters of the rule to create or update. Is either a + MetricAlertResource type or a IO type. Required. :type parameters: ~$(python-base-namespace).v2018_03_01.models.MetricAlertResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -367,9 +390,9 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricAlertResource] + api_version: Literal["2018-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MetricAlertResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -392,9 +415,9 @@ async def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -412,7 +435,9 @@ async def create_or_update( return deserialized - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}" + } @overload async def update( @@ -485,8 +510,8 @@ async def update( :type resource_group_name: str :param rule_name: The name of the rule. Required. :type rule_name: str - :param parameters: The parameters of the rule to update. Is either a model type or a IO type. - Required. + :param parameters: The parameters of the rule to update. Is either a MetricAlertResourcePatch + type or a IO type. Required. :type parameters: ~$(python-base-namespace).v2018_03_01.models.MetricAlertResourcePatch or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -507,9 +532,9 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricAlertResource] + api_version: Literal["2018-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MetricAlertResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -532,9 +557,9 @@ async def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -552,7 +577,9 @@ async def update( return deserialized - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -581,8 +608,8 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2018-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -594,9 +621,9 @@ async def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -610,4 +637,6 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/_metric_alerts_status_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/_metric_alerts_status_operations.py index 1576cd774f36..71a989c6f119 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/_metric_alerts_status_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/_metric_alerts_status_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -27,6 +28,10 @@ from ..._vendor import _convert_request from ...operations._metric_alerts_status_operations import build_list_by_name_request, build_list_request +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -77,8 +82,8 @@ async def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricAlertStatusCollection] + api_version: Literal["2018-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + cls: ClsType[_models.MetricAlertStatusCollection] = kwargs.pop("cls", None) request = build_list_request( resource_group_name=resource_group_name, @@ -90,9 +95,9 @@ async def list( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -110,7 +115,9 @@ async def list( return deserialized - list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}/status"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}/status" + } @distributed_trace_async async def list_by_name( @@ -141,8 +148,8 @@ async def list_by_name( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricAlertStatusCollection] + api_version: Literal["2018-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + cls: ClsType[_models.MetricAlertStatusCollection] = kwargs.pop("cls", None) request = build_list_by_name_request( resource_group_name=resource_group_name, @@ -155,9 +162,9 @@ async def list_by_name( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -175,4 +182,6 @@ async def list_by_name( return deserialized - list_by_name.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}/status/{statusName}"} # type: ignore + list_by_name.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}/status/{statusName}" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/__init__.py index ba7081ca121c..8dd7a2ac99a2 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/__init__.py @@ -46,7 +46,7 @@ from ._monitor_management_client_enums import Operator from ._monitor_management_client_enums import ReceiverStatus from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/_models_py3.py index cb6297144d30..903953be53c6 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/_models_py3.py @@ -13,13 +13,14 @@ from ... import _serialization -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models if sys.version_info >= (3, 9): from collections.abc import MutableMapping else: from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object @@ -38,8 +39,12 @@ class ActionGroupList(_serialization.Model): } def __init__( - self, *, value: Optional[List["_models.ActionGroupResource"]] = None, next_link: Optional[str] = None, **kwargs - ): + self, + *, + value: Optional[List["_models.ActionGroupResource"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: """ :keyword value: The list of action groups. :paramtype value: list[~$(python-base-namespace).v2018_03_01.models.ActionGroupResource] @@ -66,7 +71,7 @@ class ActionGroupPatchBody(_serialization.Model): "enabled": {"key": "properties.enabled", "type": "bool"}, } - def __init__(self, *, tags: Optional[Dict[str, str]] = None, enabled: bool = True, **kwargs): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, enabled: bool = True, **kwargs: Any) -> None: """ :keyword tags: Resource tags. :paramtype tags: dict[str, str] @@ -113,7 +118,7 @@ class Resource(_serialization.Model): "tags": {"key": "tags", "type": "{str}"}, } - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: """ :keyword location: Resource location. Required. :paramtype location: str @@ -223,8 +228,8 @@ def __init__( voice_receivers: Optional[List["_models.VoiceReceiver"]] = None, logic_app_receivers: Optional[List["_models.LogicAppReceiver"]] = None, azure_function_receivers: Optional[List["_models.AzureFunctionReceiver"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword location: Resource location. Required. :paramtype location: str @@ -323,8 +328,8 @@ def __init__( is_global_runbook: bool, name: Optional[str] = None, service_uri: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword automation_account_id: The Azure automation account Id which holds this runbook and authenticate to Azure resource. Required. @@ -371,7 +376,7 @@ class AzureAppPushReceiver(_serialization.Model): "email_address": {"key": "emailAddress", "type": "str"}, } - def __init__(self, *, name: str, email_address: str, **kwargs): + def __init__(self, *, name: str, email_address: str, **kwargs: Any) -> None: """ :keyword name: The name of the Azure mobile app push receiver. Names must be unique across all receivers within an action group. Required. @@ -415,8 +420,8 @@ class AzureFunctionReceiver(_serialization.Model): } def __init__( - self, *, name: str, function_app_resource_id: str, function_name: str, http_trigger_url: str, **kwargs - ): + self, *, name: str, function_app_resource_id: str, function_name: str, http_trigger_url: str, **kwargs: Any + ) -> None: """ :keyword name: The name of the azure function receiver. Names must be unique across all receivers within an action group. Required. @@ -501,8 +506,8 @@ def __init__( metric_namespace: Optional[str] = None, dimensions: Optional[List["_models.MetricDimension"]] = None, skip_metric_validation: Optional[bool] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword additional_properties: Unmatched properties from the message are deserialized to this collection. @@ -525,7 +530,7 @@ def __init__( """ super().__init__(**kwargs) self.additional_properties = additional_properties - self.criterion_type = None # type: Optional[str] + self.criterion_type: Optional[str] = None self.name = name self.metric_name = metric_name self.metric_namespace = metric_namespace @@ -616,8 +621,8 @@ def __init__( dimensions: Optional[List["_models.MetricDimension"]] = None, skip_metric_validation: Optional[bool] = None, ignore_data_before: Optional[datetime.datetime] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword additional_properties: Unmatched properties from the message are deserialized to this collection. @@ -664,7 +669,7 @@ def __init__( skip_metric_validation=skip_metric_validation, **kwargs ) - self.criterion_type = "DynamicThresholdCriterion" # type: str + self.criterion_type: str = "DynamicThresholdCriterion" self.operator = operator self.alert_sensitivity = alert_sensitivity self.failing_periods = failing_periods @@ -672,7 +677,8 @@ def __init__( class DynamicThresholdFailingPeriods(_serialization.Model): - """The minimum number of violations required within the selected lookback time window required to raise an alert. + """The minimum number of violations required within the selected lookback time window required to + raise an alert. All required parameters must be populated in order to send to Azure. @@ -695,7 +701,9 @@ class DynamicThresholdFailingPeriods(_serialization.Model): "min_failing_periods_to_alert": {"key": "minFailingPeriodsToAlert", "type": "float"}, } - def __init__(self, *, number_of_evaluation_periods: float, min_failing_periods_to_alert: float, **kwargs): + def __init__( + self, *, number_of_evaluation_periods: float, min_failing_periods_to_alert: float, **kwargs: Any + ) -> None: """ :keyword number_of_evaluation_periods: The number of aggregated lookback points. The lookback time window is calculated based on the aggregation granularity (windowSize) and the selected @@ -739,7 +747,7 @@ class EmailReceiver(_serialization.Model): "status": {"key": "status", "type": "str"}, } - def __init__(self, *, name: str, email_address: str, **kwargs): + def __init__(self, *, name: str, email_address: str, **kwargs: Any) -> None: """ :keyword name: The name of the email receiver. Names must be unique across all receivers within an action group. Required. @@ -770,7 +778,7 @@ class EnableRequest(_serialization.Model): "receiver_name": {"key": "receiverName", "type": "str"}, } - def __init__(self, *, receiver_name: str, **kwargs): + def __init__(self, *, receiver_name: str, **kwargs: Any) -> None: """ :keyword receiver_name: The name of the receiver to resubscribe. Required. :paramtype receiver_name: str @@ -793,7 +801,7 @@ class ErrorResponse(_serialization.Model): "message": {"key": "message", "type": "str"}, } - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: """ :keyword code: Error code. :paramtype code: str @@ -844,8 +852,8 @@ class ItsmReceiver(_serialization.Model): } def __init__( - self, *, name: str, workspace_id: str, connection_id: str, ticket_configuration: str, region: str, **kwargs - ): + self, *, name: str, workspace_id: str, connection_id: str, ticket_configuration: str, region: str, **kwargs: Any + ) -> None: """ :keyword name: The name of the Itsm receiver. Names must be unique across all receivers within an action group. Required. @@ -897,7 +905,7 @@ class LogicAppReceiver(_serialization.Model): "callback_url": {"key": "callbackUrl", "type": "str"}, } - def __init__(self, *, name: str, resource_id: str, callback_url: str, **kwargs): + def __init__(self, *, name: str, resource_id: str, callback_url: str, **kwargs: Any) -> None: """ :keyword name: The name of the logic app receiver. Names must be unique across all receivers within an action group. Required. @@ -929,8 +937,12 @@ class MetricAlertAction(_serialization.Model): } def __init__( - self, *, action_group_id: Optional[str] = None, web_hook_properties: Optional[Dict[str, str]] = None, **kwargs - ): + self, + *, + action_group_id: Optional[str] = None, + web_hook_properties: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> None: """ :keyword action_group_id: the id of the action group to use. :paramtype action_group_id: str @@ -979,7 +991,7 @@ class MetricAlertCriteria(_serialization.Model): } } - def __init__(self, *, additional_properties: Optional[Dict[str, JSON]] = None, **kwargs): + def __init__(self, *, additional_properties: Optional[Dict[str, JSON]] = None, **kwargs: Any) -> None: """ :keyword additional_properties: Unmatched properties from the message are deserialized to this collection. @@ -987,7 +999,7 @@ def __init__(self, *, additional_properties: Optional[Dict[str, JSON]] = None, * """ super().__init__(**kwargs) self.additional_properties = additional_properties - self.odata_type = None # type: Optional[str] + self.odata_type: Optional[str] = None class MetricAlertMultipleResourceMultipleMetricCriteria(MetricAlertCriteria): @@ -1022,8 +1034,8 @@ def __init__( *, additional_properties: Optional[Dict[str, JSON]] = None, all_of: Optional[List["_models.MultiMetricCriteria"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword additional_properties: Unmatched properties from the message are deserialized to this collection. @@ -1032,7 +1044,7 @@ def __init__( :paramtype all_of: list[~$(python-base-namespace).v2018_03_01.models.MultiMetricCriteria] """ super().__init__(additional_properties=additional_properties, **kwargs) - self.odata_type = "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria" # type: str + self.odata_type: str = "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria" self.all_of = all_of @@ -1142,8 +1154,8 @@ def __init__( target_resource_region: Optional[str] = None, auto_mitigate: Optional[bool] = None, actions: Optional[List["_models.MetricAlertAction"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword location: Resource location. Required. :paramtype location: str @@ -1208,7 +1220,7 @@ class MetricAlertResourceCollection(_serialization.Model): "value": {"key": "value", "type": "[MetricAlertResource]"}, } - def __init__(self, *, value: Optional[List["_models.MetricAlertResource"]] = None, **kwargs): + def __init__(self, *, value: Optional[List["_models.MetricAlertResource"]] = None, **kwargs: Any) -> None: """ :keyword value: the values for the alert rule resources. :paramtype value: list[~$(python-base-namespace).v2018_03_01.models.MetricAlertResource] @@ -1296,8 +1308,8 @@ def __init__( criteria: Optional["_models.MetricAlertCriteria"] = None, auto_mitigate: Optional[bool] = None, actions: Optional[List["_models.MetricAlertAction"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword tags: Resource tags. :paramtype tags: dict[str, str] @@ -1380,8 +1392,8 @@ def __init__( *, additional_properties: Optional[Dict[str, JSON]] = None, all_of: Optional[List["_models.MetricCriteria"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword additional_properties: Unmatched properties from the message are deserialized to this collection. @@ -1390,7 +1402,7 @@ def __init__( :paramtype all_of: list[~$(python-base-namespace).v2018_03_01.models.MetricCriteria] """ super().__init__(additional_properties=additional_properties, **kwargs) - self.odata_type = "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria" # type: str + self.odata_type: str = "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria" self.all_of = all_of @@ -1421,8 +1433,8 @@ def __init__( id: Optional[str] = None, # pylint: disable=redefined-builtin type: Optional[str] = None, properties: Optional["_models.MetricAlertStatusProperties"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: The status name. :paramtype name: str @@ -1451,7 +1463,7 @@ class MetricAlertStatusCollection(_serialization.Model): "value": {"key": "value", "type": "[MetricAlertStatus]"}, } - def __init__(self, *, value: Optional[List["_models.MetricAlertStatus"]] = None, **kwargs): + def __init__(self, *, value: Optional[List["_models.MetricAlertStatus"]] = None, **kwargs: Any) -> None: """ :keyword value: the values for the alert rule resources. :paramtype value: list[~$(python-base-namespace).v2018_03_01.models.MetricAlertStatus] @@ -1483,8 +1495,8 @@ def __init__( dimensions: Optional[Dict[str, str]] = None, status: Optional[str] = None, timestamp: Optional[datetime.datetime] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword dimensions: An object describing the type of the dimensions. :paramtype dimensions: dict[str, str] @@ -1566,8 +1578,8 @@ def __init__( metric_namespace: Optional[str] = None, dimensions: Optional[List["_models.MetricDimension"]] = None, skip_metric_validation: Optional[bool] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword additional_properties: Unmatched properties from the message are deserialized to this collection. @@ -1603,7 +1615,7 @@ def __init__( skip_metric_validation=skip_metric_validation, **kwargs ) - self.criterion_type = "StaticThresholdCriterion" # type: str + self.criterion_type: str = "StaticThresholdCriterion" self.operator = operator self.threshold = threshold @@ -1633,7 +1645,7 @@ class MetricDimension(_serialization.Model): "values": {"key": "values", "type": "[str]"}, } - def __init__(self, *, name: str, operator: str, values: List[str], **kwargs): + def __init__(self, *, name: str, operator: str, values: List[str], **kwargs: Any) -> None: """ :keyword name: Name of the dimension. Required. :paramtype name: str @@ -1682,7 +1694,7 @@ class SmsReceiver(_serialization.Model): "status": {"key": "status", "type": "str"}, } - def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs): + def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs: Any) -> None: """ :keyword name: The name of the SMS receiver. Names must be unique across all receivers within an action group. Required. @@ -1725,7 +1737,7 @@ class VoiceReceiver(_serialization.Model): "phone_number": {"key": "phoneNumber", "type": "str"}, } - def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs): + def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs: Any) -> None: """ :keyword name: The name of the voice receiver. Names must be unique across all receivers within an action group. Required. @@ -1763,7 +1775,7 @@ class WebhookReceiver(_serialization.Model): "service_uri": {"key": "serviceUri", "type": "str"}, } - def __init__(self, *, name: str, service_uri: str, **kwargs): + def __init__(self, *, name: str, service_uri: str, **kwargs: Any) -> None: """ :keyword name: The name of the webhook receiver. Names must be unique across all receivers within an action group. Required. @@ -1819,8 +1831,8 @@ def __init__( component_id: str, failed_location_count: float, additional_properties: Optional[Dict[str, JSON]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword additional_properties: Unmatched properties from the message are deserialized to this collection. @@ -1833,7 +1845,7 @@ def __init__( :paramtype failed_location_count: float """ super().__init__(additional_properties=additional_properties, **kwargs) - self.odata_type = "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria" # type: str + self.odata_type: str = "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria" self.web_test_id = web_test_id self.component_id = component_id self.failed_location_count = failed_location_count diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/__init__.py index 08442f934dbe..854cfe54a91d 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/__init__.py @@ -11,7 +11,7 @@ from ._metric_alerts_status_operations import MetricAlertsStatusOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/_action_groups_operations.py index d1f00fa896f7..d44aeaa3871c 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/_action_groups_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/_action_groups_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -42,8 +47,8 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2018-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -59,7 +64,7 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -78,7 +83,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + api_version: Literal["2018-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -94,7 +99,7 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -111,7 +116,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + api_version: Literal["2018-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -127,7 +132,7 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -144,8 +149,8 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2018-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -161,7 +166,7 @@ def build_update_request( "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -178,7 +183,7 @@ def build_list_by_subscription_id_request(subscription_id: str, **kwargs: Any) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + api_version: Literal["2018-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -187,7 +192,7 @@ def build_list_by_subscription_id_request(subscription_id: str, **kwargs: Any) - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -202,7 +207,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + api_version: Literal["2018-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -217,7 +222,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -234,8 +239,8 @@ def build_enable_receiver_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2018-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -251,7 +256,7 @@ def build_enable_receiver_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -354,8 +359,8 @@ def create_or_update( :type resource_group_name: str :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group: The action group to create or use for the update. Is either a model type - or a IO type. Required. + :param action_group: The action group to create or use for the update. Is either a + ActionGroupResource type or a IO type. Required. :type action_group: ~$(python-base-namespace).v2018_03_01.models.ActionGroupResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -376,9 +381,9 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] + api_version: Literal["2018-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -401,9 +406,9 @@ def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -421,11 +426,13 @@ def create_or_update( deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" + } @distributed_trace def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) -> _models.ActionGroupResource: @@ -452,8 +459,8 @@ def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) - _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] + api_version: Literal["2018-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -465,9 +472,9 @@ def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) - params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -485,7 +492,9 @@ def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) - return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -514,8 +523,8 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2018-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -527,9 +536,9 @@ def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -543,7 +552,9 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" + } @overload def update( @@ -616,8 +627,8 @@ def update( :type resource_group_name: str :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Is either a model type or a IO - type. Required. + :param action_group_patch: Parameters supplied to the operation. Is either a + ActionGroupPatchBody type or a IO type. Required. :type action_group_patch: ~$(python-base-namespace).v2018_03_01.models.ActionGroupPatchBody or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -639,9 +650,9 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] + api_version: Literal["2018-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -664,9 +675,9 @@ def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -684,7 +695,9 @@ def update( return deserialized - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" + } @distributed_trace def list_by_subscription_id(self, **kwargs: Any) -> Iterable["_models.ActionGroupResource"]: @@ -699,8 +712,8 @@ def list_by_subscription_id(self, **kwargs: Any) -> Iterable["_models.ActionGrou _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + api_version: Literal["2018-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -721,16 +734,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -738,13 +758,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ActionGroupList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -758,7 +778,9 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_subscription_id.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups"} # type: ignore + list_by_subscription_id.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups" + } @distributed_trace def list_by_resource_group( @@ -778,8 +800,8 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + api_version: Literal["2018-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -801,16 +823,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -818,13 +847,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ActionGroupList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -838,7 +867,9 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups" + } @overload def enable_receiver( # pylint: disable=inconsistent-return-statements @@ -914,7 +945,7 @@ def enable_receiver( # pylint: disable=inconsistent-return-statements :type resource_group_name: str :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param enable_request: The receiver to re-enable. Is either a model type or a IO type. + :param enable_request: The receiver to re-enable. Is either a EnableRequest type or a IO type. Required. :type enable_request: ~$(python-base-namespace).v2018_03_01.models.EnableRequest or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -936,9 +967,9 @@ def enable_receiver( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2018-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -961,9 +992,9 @@ def enable_receiver( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -977,4 +1008,6 @@ def enable_receiver( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - enable_receiver.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe"} # type: ignore + enable_receiver.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/_metric_alerts_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/_metric_alerts_operations.py index d5fdf9480e0f..192c56940508 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/_metric_alerts_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/_metric_alerts_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + api_version: Literal["2018-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -49,7 +54,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -64,7 +69,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + api_version: Literal["2018-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -79,7 +84,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -94,7 +99,7 @@ def build_get_request(resource_group_name: str, rule_name: str, subscription_id: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + api_version: Literal["2018-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -110,7 +115,7 @@ def build_get_request(resource_group_name: str, rule_name: str, subscription_id: "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -127,8 +132,8 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2018-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -144,7 +149,7 @@ def build_create_or_update_request( "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -161,8 +166,8 @@ def build_update_request(resource_group_name: str, rule_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2018-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -178,7 +183,7 @@ def build_update_request(resource_group_name: str, rule_name: str, subscription_ "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -195,7 +200,7 @@ def build_delete_request(resource_group_name: str, rule_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + api_version: Literal["2018-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -211,7 +216,7 @@ def build_delete_request(resource_group_name: str, rule_name: str, subscription_ "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -254,8 +259,8 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.MetricAlertRe _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricAlertResourceCollection] + api_version: Literal["2018-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + cls: ClsType[_models.MetricAlertResourceCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -276,16 +281,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -293,13 +305,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("MetricAlertResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -313,7 +325,7 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/metricAlerts"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/metricAlerts"} @distributed_trace def list_by_resource_group( @@ -333,8 +345,8 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricAlertResourceCollection] + api_version: Literal["2018-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + cls: ClsType[_models.MetricAlertResourceCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -356,16 +368,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -373,13 +392,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("MetricAlertResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -393,7 +412,9 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts" + } @distributed_trace def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _models.MetricAlertResource: @@ -420,8 +441,8 @@ def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _model _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricAlertResource] + api_version: Literal["2018-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + cls: ClsType[_models.MetricAlertResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -433,9 +454,9 @@ def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _model params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -453,7 +474,9 @@ def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _model return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}" + } @overload def create_or_update( @@ -526,8 +549,8 @@ def create_or_update( :type resource_group_name: str :param rule_name: The name of the rule. Required. :type rule_name: str - :param parameters: The parameters of the rule to create or update. Is either a model type or a - IO type. Required. + :param parameters: The parameters of the rule to create or update. Is either a + MetricAlertResource type or a IO type. Required. :type parameters: ~$(python-base-namespace).v2018_03_01.models.MetricAlertResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -548,9 +571,9 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricAlertResource] + api_version: Literal["2018-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MetricAlertResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -573,9 +596,9 @@ def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -593,7 +616,9 @@ def create_or_update( return deserialized - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}" + } @overload def update( @@ -666,8 +691,8 @@ def update( :type resource_group_name: str :param rule_name: The name of the rule. Required. :type rule_name: str - :param parameters: The parameters of the rule to update. Is either a model type or a IO type. - Required. + :param parameters: The parameters of the rule to update. Is either a MetricAlertResourcePatch + type or a IO type. Required. :type parameters: ~$(python-base-namespace).v2018_03_01.models.MetricAlertResourcePatch or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -688,9 +713,9 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricAlertResource] + api_version: Literal["2018-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MetricAlertResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -713,9 +738,9 @@ def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -733,7 +758,9 @@ def update( return deserialized - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -762,8 +789,8 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2018-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -775,9 +802,9 @@ def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -791,4 +818,6 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/_metric_alerts_status_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/_metric_alerts_status_operations.py index 26bf308a09a4..6d7b0e7ab8b9 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/_metric_alerts_status_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/_metric_alerts_status_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -27,6 +28,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -38,7 +43,7 @@ def build_list_request(resource_group_name: str, rule_name: str, subscription_id _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + api_version: Literal["2018-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -54,7 +59,7 @@ def build_list_request(resource_group_name: str, rule_name: str, subscription_id "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -71,7 +76,7 @@ def build_list_by_name_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str + api_version: Literal["2018-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -88,7 +93,7 @@ def build_list_by_name_request( "statusName": _SERIALIZER.url("status_name", status_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -143,8 +148,8 @@ def list(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _mode _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricAlertStatusCollection] + api_version: Literal["2018-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + cls: ClsType[_models.MetricAlertStatusCollection] = kwargs.pop("cls", None) request = build_list_request( resource_group_name=resource_group_name, @@ -156,9 +161,9 @@ def list(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _mode params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -176,7 +181,9 @@ def list(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _mode return deserialized - list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}/status"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}/status" + } @distributed_trace def list_by_name( @@ -207,8 +214,8 @@ def list_by_name( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricAlertStatusCollection] + api_version: Literal["2018-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-03-01")) + cls: ClsType[_models.MetricAlertStatusCollection] = kwargs.pop("cls", None) request = build_list_by_name_request( resource_group_name=resource_group_name, @@ -221,9 +228,9 @@ def list_by_name( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -241,4 +248,6 @@ def list_by_name( return deserialized - list_by_name.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}/status/{statusName}"} # type: ignore + list_by_name.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}/status/{statusName}" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/__init__.py index 8ba4823444a9..2c7733bfd566 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/__init__.py @@ -13,12 +13,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["MonitorManagementClient"] +__all__ = [ + "MonitorManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_configuration.py index a9a360483411..90a10fa7b275 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -36,7 +42,7 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2018-04-16") # type: str + api_version: Literal["2018-04-16"] = kwargs.pop("api_version", "2018-04-16") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -50,10 +56,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, **kwargs # type: Any - ): - # type: (...) -> None + def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_metadata.json index 2d06e0f25ce0..23673fec1434 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_metadata.json @@ -19,13 +19,15 @@ "signature": "credential: \"TokenCredential\",", "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true + "required": true, + "method_location": "positional" }, "subscription_id": { "signature": "subscription_id: str,", "description": "The ID of the target subscription. Required.", "docstring_type": "str", - "required": true + "required": true, + "method_location": "positional" } }, "async": { @@ -48,22 +50,25 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "signature": "api_version: Optional[str]=None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } }, "async": { @@ -71,19 +76,22 @@ "signature": "api_version: Optional[str] = None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { "signature": "profile: KnownProfiles = KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } } } @@ -99,4 +107,4 @@ "operation_groups": { "scheduled_query_rules": "ScheduledQueryRulesOperations" } -} \ No newline at end of file +} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_monitor_management_client.py index eac33aa08ac4..ad284b268e2b 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_monitor_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from . import models +from . import models as _models from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ScheduledQueryRulesOperations @@ -51,7 +51,7 @@ def __init__( ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -81,15 +81,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> MonitorManagementClient + def __enter__(self) -> "MonitorManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_vendor.py index 9aad73fc743e..bd0df84f5319 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_vendor.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_vendor.py @@ -5,6 +5,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import List, cast + from azure.core.pipeline.transport import HttpRequest @@ -22,6 +24,7 @@ def _format_url_section(template, **kwargs): try: return template.format(**kwargs) except KeyError as key: - formatted_components = template.split("/") + # Need the cast, as for some reasons "split" is typed as list[str | Any] + formatted_components = cast(List[str], template.split("/")) components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_version.py index ce9ac7ae37b3..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/__init__.py index 8638dc69d869..2c151bb41c19 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/__init__.py @@ -10,12 +10,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["MonitorManagementClient"] +__all__ = [ + "MonitorManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/_configuration.py index fa652aba27f3..01cea85a1b06 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -36,7 +42,7 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2018-04-16") # type: str + api_version: Literal["2018-04-16"] = kwargs.pop("api_version", "2018-04-16") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/_monitor_management_client.py index cbe6779ef9c0..6cbefabb2622 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/_monitor_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from .. import models +from .. import models as _models from ..._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ScheduledQueryRulesOperations @@ -51,7 +51,7 @@ def __init__( ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -88,5 +88,5 @@ async def __aenter__(self) -> "MonitorManagementClient": await self._client.__aenter__() return self - async def __aexit__(self, *exc_details) -> None: + async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/operations/__init__.py index 40cd07056c01..e010c281d4fc 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/operations/__init__.py @@ -9,7 +9,7 @@ from ._scheduled_query_rules_operations import ScheduledQueryRulesOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/operations/_scheduled_query_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/operations/_scheduled_query_rules_operations.py index b9e64a3bf27a..08f540d9939a 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/operations/_scheduled_query_rules_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/operations/_scheduled_query_rules_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -37,6 +38,10 @@ build_update_request, ) +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -131,8 +136,8 @@ async def create_or_update( :type resource_group_name: str :param rule_name: The name of the rule. Required. :type rule_name: str - :param parameters: The parameters of the rule to create or update. Is either a model type or a - IO type. Required. + :param parameters: The parameters of the rule to create or update. Is either a + LogSearchRuleResource type or a IO type. Required. :type parameters: ~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -153,9 +158,9 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.LogSearchRuleResource] + api_version: Literal["2018-04-16"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LogSearchRuleResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -178,9 +183,9 @@ async def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -198,11 +203,13 @@ async def create_or_update( deserialized = self._deserialize("LogSearchRuleResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}" + } @distributed_trace_async async def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _models.LogSearchRuleResource: @@ -229,8 +236,8 @@ async def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.LogSearchRuleResource] + api_version: Literal["2018-04-16"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) + cls: ClsType[_models.LogSearchRuleResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -242,9 +249,9 @@ async def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -262,7 +269,9 @@ async def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}" + } @overload async def update( @@ -335,8 +344,8 @@ async def update( :type resource_group_name: str :param rule_name: The name of the rule. Required. :type rule_name: str - :param parameters: The parameters of the rule to update. Is either a model type or a IO type. - Required. + :param parameters: The parameters of the rule to update. Is either a LogSearchRuleResourcePatch + type or a IO type. Required. :type parameters: ~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResourcePatch or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -357,9 +366,9 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.LogSearchRuleResource] + api_version: Literal["2018-04-16"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LogSearchRuleResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -382,9 +391,9 @@ async def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -402,7 +411,9 @@ async def update( return deserialized - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -431,8 +442,8 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2018-04-16"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -444,9 +455,9 @@ async def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -460,7 +471,9 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}" + } @distributed_trace def list_by_subscription( @@ -481,8 +494,8 @@ def list_by_subscription( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.LogSearchRuleResourceCollection] + api_version: Literal["2018-04-16"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) + cls: ClsType[_models.LogSearchRuleResourceCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -504,16 +517,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -521,13 +541,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("LogSearchRuleResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -541,7 +561,9 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/scheduledQueryRules"} # type: ignore + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/scheduledQueryRules" + } @distributed_trace def list_by_resource_group( @@ -565,8 +587,8 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.LogSearchRuleResourceCollection] + api_version: Literal["2018-04-16"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) + cls: ClsType[_models.LogSearchRuleResourceCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -589,16 +611,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -606,13 +635,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("LogSearchRuleResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -626,4 +655,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/__init__.py index 15975e5d06a0..72a250bda7be 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/__init__.py @@ -31,7 +31,7 @@ from ._monitor_management_client_enums import ProvisioningState from ._monitor_management_client_enums import QueryType from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/_models_py3.py index 3e1ad7562fce..cb07c3096b06 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/_models_py3.py @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Dict, List, Optional, TYPE_CHECKING, Union +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union from ... import _serialization @@ -44,10 +44,10 @@ class Action(_serialization.Model): } } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.odata_type = None # type: Optional[str] + self.odata_type: Optional[str] = None class AlertingAction(Action): @@ -89,8 +89,8 @@ def __init__( trigger: "_models.TriggerCondition", azns_action: Optional["_models.AzNsActionGroup"] = None, throttling_in_min: Optional[int] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword severity: Severity of the alert. Required. Known values are: "0", "1", "2", "3", and "4". @@ -104,7 +104,7 @@ def __init__( :paramtype trigger: ~$(python-base-namespace).v2018_04_16.models.TriggerCondition """ super().__init__(**kwargs) - self.odata_type = "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction" # type: str + self.odata_type: str = "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction" self.severity = severity self.azns_action = azns_action self.throttling_in_min = throttling_in_min @@ -135,8 +135,8 @@ def __init__( action_group: Optional[List[str]] = None, email_subject: Optional[str] = None, custom_webhook_payload: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword action_group: Azure Action Group reference. :paramtype action_group: list[str] @@ -172,7 +172,9 @@ class Criteria(_serialization.Model): "dimensions": {"key": "dimensions", "type": "[Dimension]"}, } - def __init__(self, *, metric_name: str, dimensions: Optional[List["_models.Dimension"]] = None, **kwargs): + def __init__( + self, *, metric_name: str, dimensions: Optional[List["_models.Dimension"]] = None, **kwargs: Any + ) -> None: """ :keyword metric_name: Name of the metric. Required. :paramtype metric_name: str @@ -209,7 +211,9 @@ class Dimension(_serialization.Model): "values": {"key": "values", "type": "[str]"}, } - def __init__(self, *, name: str, operator: Union[str, "_models.Operator"], values: List[str], **kwargs): + def __init__( + self, *, name: str, operator: Union[str, "_models.Operator"], values: List[str], **kwargs: Any + ) -> None: """ :keyword name: Name of the dimension. Required. :paramtype name: str @@ -235,7 +239,7 @@ class ErrorContract(_serialization.Model): "error": {"key": "error", "type": "ErrorResponse"}, } - def __init__(self, *, error: Optional["_models.ErrorResponse"] = None, **kwargs): + def __init__(self, *, error: Optional["_models.ErrorResponse"] = None, **kwargs: Any) -> None: """ :keyword error: The error details. :paramtype error: ~$(python-base-namespace).v2018_04_16.models.ErrorResponse @@ -258,7 +262,7 @@ class ErrorResponse(_serialization.Model): "message": {"key": "message", "type": "str"}, } - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: """ :keyword code: Error code. :paramtype code: str @@ -302,8 +306,8 @@ def __init__( threshold: Optional[float] = None, metric_trigger_type: Union[str, "_models.MetricTriggerType"] = "Consecutive", metric_column: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword threshold_operator: Evaluation operation for Metric -'GreaterThan' or 'LessThan' or 'Equal'. Known values are: "GreaterThanOrEqual", "LessThanOrEqual", "GreaterThan", "LessThan", @@ -374,7 +378,7 @@ class Resource(_serialization.Model): "etag": {"key": "etag", "type": "str"}, } - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: """ :keyword location: Resource location. Required. :paramtype location: str @@ -495,8 +499,8 @@ def __init__( auto_mitigate: bool = False, enabled: Optional[Union[str, "_models.Enabled"]] = None, schedule: Optional["_models.Schedule"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword location: Resource location. Required. :paramtype location: str @@ -545,7 +549,7 @@ class LogSearchRuleResourceCollection(_serialization.Model): "value": {"key": "value", "type": "[LogSearchRuleResource]"}, } - def __init__(self, *, value: Optional[List["_models.LogSearchRuleResource"]] = None, **kwargs): + def __init__(self, *, value: Optional[List["_models.LogSearchRuleResource"]] = None, **kwargs: Any) -> None: """ :keyword value: The values for the Log Search Rule resources. :paramtype value: list[~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResource] @@ -574,8 +578,8 @@ def __init__( *, tags: Optional[Dict[str, str]] = None, enabled: Optional[Union[str, "_models.Enabled"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword tags: Resource tags. :paramtype tags: dict[str, str] @@ -610,13 +614,13 @@ class LogToMetricAction(Action): "criteria": {"key": "criteria", "type": "[Criteria]"}, } - def __init__(self, *, criteria: List["_models.Criteria"], **kwargs): + def __init__(self, *, criteria: List["_models.Criteria"], **kwargs: Any) -> None: """ :keyword criteria: Criteria of Metric. Required. :paramtype criteria: list[~$(python-base-namespace).v2018_04_16.models.Criteria] """ super().__init__(**kwargs) - self.odata_type = "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.LogToMetricAction" # type: str + self.odata_type: str = "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.LogToMetricAction" self.criteria = criteria @@ -643,7 +647,7 @@ class Schedule(_serialization.Model): "time_window_in_minutes": {"key": "timeWindowInMinutes", "type": "int"}, } - def __init__(self, *, frequency_in_minutes: int, time_window_in_minutes: int, **kwargs): + def __init__(self, *, frequency_in_minutes: int, time_window_in_minutes: int, **kwargs: Any) -> None: """ :keyword frequency_in_minutes: frequency (in minutes) at which rule condition should be evaluated. Required. @@ -690,8 +694,8 @@ def __init__( query: Optional[str] = None, authorized_resources: Optional[List[str]] = None, query_type: Optional[Union[str, "_models.QueryType"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword query: Log search query. Required for action type - AlertingAction. :paramtype query: str @@ -741,8 +745,8 @@ def __init__( threshold_operator: Union[str, "_models.ConditionalOperator"] = "GreaterThanOrEqual", threshold: float, metric_trigger: Optional["_models.LogMetricTrigger"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword threshold_operator: Evaluation operation for rule - 'GreaterThan' or 'LessThan. Known values are: "GreaterThanOrEqual", "LessThanOrEqual", "GreaterThan", "LessThan", and "Equal". diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/operations/__init__.py index 40cd07056c01..e010c281d4fc 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/operations/__init__.py @@ -9,7 +9,7 @@ from ._scheduled_query_rules_operations import ScheduledQueryRulesOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/operations/_scheduled_query_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/operations/_scheduled_query_rules_operations.py index b4c63358849a..acf2784e65c9 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/operations/_scheduled_query_rules_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/operations/_scheduled_query_rules_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -42,8 +47,8 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2018-04-16"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -59,7 +64,7 @@ def build_create_or_update_request( "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -76,7 +81,7 @@ def build_get_request(resource_group_name: str, rule_name: str, subscription_id: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) # type: str + api_version: Literal["2018-04-16"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -92,7 +97,7 @@ def build_get_request(resource_group_name: str, rule_name: str, subscription_id: "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -107,8 +112,8 @@ def build_update_request(resource_group_name: str, rule_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2018-04-16"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -124,7 +129,7 @@ def build_update_request(resource_group_name: str, rule_name: str, subscription_ "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -141,7 +146,7 @@ def build_delete_request(resource_group_name: str, rule_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) # type: str + api_version: Literal["2018-04-16"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -157,7 +162,7 @@ def build_delete_request(resource_group_name: str, rule_name: str, subscription_ "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -174,7 +179,7 @@ def build_list_by_subscription_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) # type: str + api_version: Literal["2018-04-16"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -185,7 +190,7 @@ def build_list_by_subscription_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -204,7 +209,7 @@ def build_list_by_resource_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) # type: str + api_version: Literal["2018-04-16"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -219,7 +224,7 @@ def build_list_by_resource_group_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -322,8 +327,8 @@ def create_or_update( :type resource_group_name: str :param rule_name: The name of the rule. Required. :type rule_name: str - :param parameters: The parameters of the rule to create or update. Is either a model type or a - IO type. Required. + :param parameters: The parameters of the rule to create or update. Is either a + LogSearchRuleResource type or a IO type. Required. :type parameters: ~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -344,9 +349,9 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.LogSearchRuleResource] + api_version: Literal["2018-04-16"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LogSearchRuleResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -369,9 +374,9 @@ def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -389,11 +394,13 @@ def create_or_update( deserialized = self._deserialize("LogSearchRuleResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}" + } @distributed_trace def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _models.LogSearchRuleResource: @@ -420,8 +427,8 @@ def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _model _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.LogSearchRuleResource] + api_version: Literal["2018-04-16"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) + cls: ClsType[_models.LogSearchRuleResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -433,9 +440,9 @@ def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _model params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -453,7 +460,9 @@ def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _model return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}" + } @overload def update( @@ -526,8 +535,8 @@ def update( :type resource_group_name: str :param rule_name: The name of the rule. Required. :type rule_name: str - :param parameters: The parameters of the rule to update. Is either a model type or a IO type. - Required. + :param parameters: The parameters of the rule to update. Is either a LogSearchRuleResourcePatch + type or a IO type. Required. :type parameters: ~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResourcePatch or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -548,9 +557,9 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.LogSearchRuleResource] + api_version: Literal["2018-04-16"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.LogSearchRuleResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -573,9 +582,9 @@ def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -593,7 +602,9 @@ def update( return deserialized - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -622,8 +633,8 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2018-04-16"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -635,9 +646,9 @@ def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -651,7 +662,9 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}" + } @distributed_trace def list_by_subscription( @@ -672,8 +685,8 @@ def list_by_subscription( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.LogSearchRuleResourceCollection] + api_version: Literal["2018-04-16"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) + cls: ClsType[_models.LogSearchRuleResourceCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -695,16 +708,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -712,13 +732,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("LogSearchRuleResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -732,7 +752,9 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/scheduledQueryRules"} # type: ignore + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/scheduledQueryRules" + } @distributed_trace def list_by_resource_group( @@ -756,8 +778,8 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.LogSearchRuleResourceCollection] + api_version: Literal["2018-04-16"] = kwargs.pop("api_version", _params.pop("api-version", "2018-04-16")) + cls: ClsType[_models.LogSearchRuleResourceCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -780,16 +802,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -797,13 +826,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("LogSearchRuleResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -817,4 +846,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/__init__.py index 8ba4823444a9..2c7733bfd566 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/__init__.py @@ -13,12 +13,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["MonitorManagementClient"] +__all__ = [ + "MonitorManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_configuration.py index 0d9de72334c0..75fb9a1e1263 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -36,7 +42,7 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2018-06-01-preview") # type: str + api_version: Literal["2018-06-01-preview"] = kwargs.pop("api_version", "2018-06-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -50,10 +56,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, **kwargs # type: Any - ): - # type: (...) -> None + def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_metadata.json index 2fc810ba4b99..a48d09b87bd5 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_metadata.json @@ -19,13 +19,15 @@ "signature": "credential: \"TokenCredential\",", "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true + "required": true, + "method_location": "positional" }, "subscription_id": { "signature": "subscription_id: str,", "description": "The ID of the target subscription. Required.", "docstring_type": "str", - "required": true + "required": true, + "method_location": "positional" } }, "async": { @@ -48,22 +50,25 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "signature": "api_version: Optional[str]=None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } }, "async": { @@ -71,19 +76,22 @@ "signature": "api_version: Optional[str] = None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { "signature": "profile: KnownProfiles = KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } } } @@ -100,4 +108,4 @@ "guest_diagnostics_settings_association": "GuestDiagnosticsSettingsAssociationOperations", "guest_diagnostics_settings": "GuestDiagnosticsSettingsOperations" } -} \ No newline at end of file +} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_monitor_management_client.py index 65882cf4ce27..bd1fa020ce2d 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_monitor_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from . import models +from . import models as _models from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import GuestDiagnosticsSettingsAssociationOperations, GuestDiagnosticsSettingsOperations @@ -55,7 +55,7 @@ def __init__( ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -88,15 +88,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> MonitorManagementClient + def __enter__(self) -> "MonitorManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_vendor.py index 9aad73fc743e..bd0df84f5319 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_vendor.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_vendor.py @@ -5,6 +5,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import List, cast + from azure.core.pipeline.transport import HttpRequest @@ -22,6 +24,7 @@ def _format_url_section(template, **kwargs): try: return template.format(**kwargs) except KeyError as key: - formatted_components = template.split("/") + # Need the cast, as for some reasons "split" is typed as list[str | Any] + formatted_components = cast(List[str], template.split("/")) components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_version.py index ce9ac7ae37b3..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/__init__.py index 8638dc69d869..2c151bb41c19 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/__init__.py @@ -10,12 +10,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["MonitorManagementClient"] +__all__ = [ + "MonitorManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/_configuration.py index ca9cf8a48d4e..0b8eb8e469be 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -36,7 +42,7 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2018-06-01-preview") # type: str + api_version: Literal["2018-06-01-preview"] = kwargs.pop("api_version", "2018-06-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/_monitor_management_client.py index 32df5781f744..1d914d4b8d85 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/_monitor_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from .. import models +from .. import models as _models from ..._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import GuestDiagnosticsSettingsAssociationOperations, GuestDiagnosticsSettingsOperations @@ -55,7 +55,7 @@ def __init__( ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -95,5 +95,5 @@ async def __aenter__(self) -> "MonitorManagementClient": await self._client.__aenter__() return self - async def __aexit__(self, *exc_details) -> None: + async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/operations/__init__.py index 89e22142c71f..2f4965e07c4c 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/operations/__init__.py @@ -10,7 +10,7 @@ from ._guest_diagnostics_settings_operations import GuestDiagnosticsSettingsOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/operations/_guest_diagnostics_settings_association_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/operations/_guest_diagnostics_settings_association_operations.py index 26d3d36d03c1..ff1334754b48 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/operations/_guest_diagnostics_settings_association_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/operations/_guest_diagnostics_settings_association_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -37,6 +38,10 @@ build_update_request, ) +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -137,7 +142,7 @@ async def create_or_update( :param association_name: The name of the diagnostic settings association. Required. :type association_name: str :param diagnostic_settings_association: The diagnostic settings association to create or - update. Is either a model type or a IO type. Required. + update. Is either a GuestDiagnosticSettingsAssociationResource type or a IO type. Required. :type diagnostic_settings_association: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource or IO @@ -161,9 +166,11 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.GuestDiagnosticSettingsAssociationResource] + api_version: Literal["2018-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GuestDiagnosticSettingsAssociationResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -185,9 +192,9 @@ async def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -205,11 +212,13 @@ async def create_or_update( deserialized = self._deserialize("GuestDiagnosticSettingsAssociationResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}"} # type: ignore + create_or_update.metadata = { + "url": "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}" + } @distributed_trace_async async def get( @@ -239,8 +248,10 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.GuestDiagnosticSettingsAssociationResource] + api_version: Literal["2018-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-06-01-preview") + ) + cls: ClsType[_models.GuestDiagnosticSettingsAssociationResource] = kwargs.pop("cls", None) request = build_get_request( resource_uri=resource_uri, @@ -251,9 +262,9 @@ async def get( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -271,7 +282,9 @@ async def get( return deserialized - get.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}"} # type: ignore + get.metadata = { + "url": "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -300,8 +313,10 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2018-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_uri=resource_uri, @@ -312,9 +327,9 @@ async def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -328,7 +343,9 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}"} # type: ignore + delete.metadata = { + "url": "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}" + } @overload async def update( @@ -407,8 +424,8 @@ async def update( :type resource_uri: str :param association_name: The name of the diagnostic settings association. Required. :type association_name: str - :param parameters: Parameters supplied to the operation. Is either a model type or a IO type. - Required. + :param parameters: Parameters supplied to the operation. Is either a + GuestDiagnosticSettingsAssociationResourcePatch type or a IO type. Required. :type parameters: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResourcePatch or IO @@ -432,9 +449,11 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.GuestDiagnosticSettingsAssociationResource] + api_version: Literal["2018-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GuestDiagnosticSettingsAssociationResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -456,9 +475,9 @@ async def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -476,7 +495,9 @@ async def update( return deserialized - update.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}"} # type: ignore + update.metadata = { + "url": "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}" + } @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.GuestDiagnosticSettingsAssociationResource"]: @@ -492,8 +513,10 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.GuestDiagnosticSettingsA _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.GuestDiagnosticSettingsAssociationList] + api_version: Literal["2018-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-06-01-preview") + ) + cls: ClsType[_models.GuestDiagnosticSettingsAssociationList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -514,16 +537,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -531,13 +561,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("GuestDiagnosticSettingsAssociationList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -551,7 +581,9 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/guestDiagnosticSettingsAssociations"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/guestDiagnosticSettingsAssociations" + } @distributed_trace def list_by_resource_group( @@ -572,8 +604,10 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.GuestDiagnosticSettingsAssociationList] + api_version: Literal["2018-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-06-01-preview") + ) + cls: ClsType[_models.GuestDiagnosticSettingsAssociationList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -595,16 +629,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -612,13 +653,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("GuestDiagnosticSettingsAssociationList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -632,4 +673,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettingsAssociations"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettingsAssociations" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/operations/_guest_diagnostics_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/operations/_guest_diagnostics_settings_operations.py index 188eaad5d25a..7aa47e35524a 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/operations/_guest_diagnostics_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/operations/_guest_diagnostics_settings_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -37,6 +38,10 @@ build_update_request, ) +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -132,8 +137,8 @@ async def create_or_update( :type resource_group_name: str :param diagnostic_settings_name: The name of the diagnostic setting. Required. :type diagnostic_settings_name: str - :param diagnostic_settings: The configuration to create or update. Is either a model type or a - IO type. Required. + :param diagnostic_settings: The configuration to create or update. Is either a + GuestDiagnosticSettingsResource type or a IO type. Required. :type diagnostic_settings: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -155,9 +160,11 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.GuestDiagnosticSettingsResource] + api_version: Literal["2018-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GuestDiagnosticSettingsResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -180,9 +187,9 @@ async def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -200,11 +207,13 @@ async def create_or_update( deserialized = self._deserialize("GuestDiagnosticSettingsResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}" + } @distributed_trace_async async def get( @@ -233,8 +242,10 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.GuestDiagnosticSettingsResource] + api_version: Literal["2018-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-06-01-preview") + ) + cls: ClsType[_models.GuestDiagnosticSettingsResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -246,9 +257,9 @@ async def get( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -266,7 +277,9 @@ async def get( return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}" + } @overload async def update( @@ -340,7 +353,8 @@ async def update( :type resource_group_name: str :param diagnostic_settings_name: The name of the diagnostic setting. Required. :type diagnostic_settings_name: str - :param parameters: The configuration to patch. Is either a model type or a IO type. Required. + :param parameters: The configuration to patch. Is either a GuestDiagnosticSettingsPatchResource + type or a IO type. Required. :type parameters: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsPatchResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -362,9 +376,11 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.GuestDiagnosticSettingsResource] + api_version: Literal["2018-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GuestDiagnosticSettingsResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -387,9 +403,9 @@ async def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -407,11 +423,13 @@ async def update( deserialized = self._deserialize("GuestDiagnosticSettingsResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -440,8 +458,10 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2018-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -453,9 +473,9 @@ async def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -469,7 +489,9 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}" + } @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.GuestDiagnosticSettingsResource"]: @@ -485,8 +507,10 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.GuestDiagnosticSettingsR _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.GuestDiagnosticSettingsList] + api_version: Literal["2018-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-06-01-preview") + ) + cls: ClsType[_models.GuestDiagnosticSettingsList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -507,16 +531,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -524,13 +555,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("GuestDiagnosticSettingsList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -544,7 +575,7 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/guestDiagnosticSettings"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/guestDiagnosticSettings"} @distributed_trace def list_by_resource_group( @@ -565,8 +596,10 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.GuestDiagnosticSettingsList] + api_version: Literal["2018-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-06-01-preview") + ) + cls: ClsType[_models.GuestDiagnosticSettingsList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -588,16 +621,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -605,13 +645,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("GuestDiagnosticSettingsList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -625,4 +665,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/__init__.py index 036aae01a835..4fa4abe4c38f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/__init__.py @@ -26,7 +26,7 @@ from ._monitor_management_client_enums import GuestDiagnosticSettingsOsType from ._monitor_management_client_enums import SinkConfigurationKind from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/_models_py3.py index 7defcd9a1e02..2df05d2b8700 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/_models_py3.py @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Dict, List, Optional, TYPE_CHECKING, Union +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union from ... import _serialization @@ -17,7 +17,8 @@ class DataSource(_serialization.Model): - """Data source object contains configuration to collect telemetry and one or more sinks to send that telemetry data to. + """Data source object contains configuration to collect telemetry and one or more sinks to send + that telemetry data to. All required parameters must be populated in order to send to Azure. @@ -49,8 +50,8 @@ def __init__( kind: Union[str, "_models.DataSourceKind"], configuration: "_models.DataSourceConfiguration", sinks: List["_models.SinkConfiguration"], - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword kind: Datasource kind. Required. Known values are: "PerformanceCounter", "ETWProviders", and "WindowsEventLogs". @@ -93,8 +94,8 @@ def __init__( providers: Optional[List["_models.EtwProviderConfiguration"]] = None, perf_counters: Optional[List["_models.PerformanceCounterConfiguration"]] = None, event_logs: Optional[List["_models.EventLogConfiguration"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword providers: ETW providers configuration. :paramtype providers: @@ -126,7 +127,7 @@ class ErrorResponse(_serialization.Model): "message": {"key": "message", "type": "str"}, } - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: """ :keyword code: Error code. :paramtype code: str @@ -168,8 +169,8 @@ def __init__( name: str, id: int, # pylint: disable=redefined-builtin filter: Optional[str] = None, # pylint: disable=redefined-builtin - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: Required. :paramtype name: str @@ -207,8 +208,12 @@ class EtwProviderConfiguration(_serialization.Model): } def __init__( - self, *, id: str, events: List["_models.EtwEventConfiguration"], **kwargs # pylint: disable=redefined-builtin - ): + self, + *, + id: str, # pylint: disable=redefined-builtin + events: List["_models.EtwEventConfiguration"], + **kwargs: Any + ) -> None: """ :keyword id: Required. :paramtype id: str @@ -241,7 +246,9 @@ class EventLogConfiguration(_serialization.Model): "filter": {"key": "filter", "type": "str"}, } - def __init__(self, *, log_name: str, filter: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin + def __init__( + self, *, log_name: str, filter: Optional[str] = None, **kwargs: Any # pylint: disable=redefined-builtin + ) -> None: """ :keyword log_name: Required. :paramtype log_name: str @@ -273,8 +280,8 @@ def __init__( *, value: Optional[List["_models.GuestDiagnosticSettingsAssociationResource"]] = None, next_link: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword value: The list of guest diagnostic settings association. :paramtype value: @@ -321,7 +328,7 @@ class Resource(_serialization.Model): "tags": {"key": "tags", "type": "{str}"}, } - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: """ :keyword location: Resource location. Required. :paramtype location: str @@ -375,8 +382,13 @@ class GuestDiagnosticSettingsAssociationResource(Resource): } def __init__( - self, *, location: str, guest_diagnostic_settings_name: str, tags: Optional[Dict[str, str]] = None, **kwargs - ): + self, + *, + location: str, + guest_diagnostic_settings_name: str, + tags: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> None: """ :keyword location: Resource location. Required. :paramtype location: str @@ -404,8 +416,12 @@ class GuestDiagnosticSettingsAssociationResourcePatch(_serialization.Model): } def __init__( - self, *, tags: Optional[Dict[str, str]] = None, guest_diagnostic_settings_name: Optional[str] = None, **kwargs - ): + self, + *, + tags: Optional[Dict[str, str]] = None, + guest_diagnostic_settings_name: Optional[str] = None, + **kwargs: Any + ) -> None: """ :keyword tags: Resource tags. :paramtype tags: dict[str, str] @@ -437,8 +453,8 @@ def __init__( *, value: Optional[List["_models.GuestDiagnosticSettingsResource"]] = None, next_link: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword value: The list of guest diagnostic settings. :paramtype value: @@ -481,8 +497,8 @@ def __init__( os_type: Optional[Union[str, "_models.GuestDiagnosticSettingsOsType"]] = None, data_sources: Optional[List["_models.DataSource"]] = None, proxy_setting: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword tags: Resource tags. :paramtype tags: dict[str, str] @@ -557,8 +573,8 @@ def __init__( os_type: Optional[Union[str, "_models.GuestDiagnosticSettingsOsType"]] = None, data_sources: Optional[List["_models.DataSource"]] = None, proxy_setting: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword location: Resource location. Required. :paramtype location: str @@ -604,7 +620,7 @@ class PerformanceCounterConfiguration(_serialization.Model): "instance": {"key": "instance", "type": "str"}, } - def __init__(self, *, name: str, sampling_period: str, instance: Optional[str] = None, **kwargs): + def __init__(self, *, name: str, sampling_period: str, instance: Optional[str] = None, **kwargs: Any) -> None: """ :keyword name: Required. :paramtype name: str @@ -637,7 +653,7 @@ class SinkConfiguration(_serialization.Model): "kind": {"key": "kind", "type": "str"}, } - def __init__(self, *, kind: Union[str, "_models.SinkConfigurationKind"], **kwargs): + def __init__(self, *, kind: Union[str, "_models.SinkConfigurationKind"], **kwargs: Any) -> None: """ :keyword kind: Required. Known values are: "EventHub", "ApplicationInsights", and "LogAnalytics". diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/operations/__init__.py index 89e22142c71f..2f4965e07c4c 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/operations/__init__.py @@ -10,7 +10,7 @@ from ._guest_diagnostics_settings_operations import GuestDiagnosticsSettingsOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/operations/_guest_diagnostics_settings_association_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/operations/_guest_diagnostics_settings_association_operations.py index c51802c76201..38f9116a7333 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/operations/_guest_diagnostics_settings_association_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/operations/_guest_diagnostics_settings_association_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,8 +45,10 @@ def build_create_or_update_request(resource_uri: str, association_name: str, **k _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2018-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -54,7 +61,7 @@ def build_create_or_update_request(resource_uri: str, association_name: str, **k "associationName": _SERIALIZER.url("association_name", association_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -71,7 +78,9 @@ def build_get_request(resource_uri: str, association_name: str, **kwargs: Any) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str + api_version: Literal["2018-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-06-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -84,7 +93,7 @@ def build_get_request(resource_uri: str, association_name: str, **kwargs: Any) - "associationName": _SERIALIZER.url("association_name", association_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -99,7 +108,9 @@ def build_delete_request(resource_uri: str, association_name: str, **kwargs: Any _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str + api_version: Literal["2018-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-06-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -112,7 +123,7 @@ def build_delete_request(resource_uri: str, association_name: str, **kwargs: Any "associationName": _SERIALIZER.url("association_name", association_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -127,8 +138,10 @@ def build_update_request(resource_uri: str, association_name: str, **kwargs: Any _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2018-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -141,7 +154,7 @@ def build_update_request(resource_uri: str, association_name: str, **kwargs: Any "associationName": _SERIALIZER.url("association_name", association_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -158,7 +171,9 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str + api_version: Literal["2018-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-06-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -170,7 +185,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -185,7 +200,9 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str + api_version: Literal["2018-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-06-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -200,7 +217,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -307,7 +324,7 @@ def create_or_update( :param association_name: The name of the diagnostic settings association. Required. :type association_name: str :param diagnostic_settings_association: The diagnostic settings association to create or - update. Is either a model type or a IO type. Required. + update. Is either a GuestDiagnosticSettingsAssociationResource type or a IO type. Required. :type diagnostic_settings_association: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource or IO @@ -331,9 +348,11 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.GuestDiagnosticSettingsAssociationResource] + api_version: Literal["2018-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GuestDiagnosticSettingsAssociationResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -355,9 +374,9 @@ def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -375,11 +394,13 @@ def create_or_update( deserialized = self._deserialize("GuestDiagnosticSettingsAssociationResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}"} # type: ignore + create_or_update.metadata = { + "url": "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}" + } @distributed_trace def get( @@ -409,8 +430,10 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.GuestDiagnosticSettingsAssociationResource] + api_version: Literal["2018-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-06-01-preview") + ) + cls: ClsType[_models.GuestDiagnosticSettingsAssociationResource] = kwargs.pop("cls", None) request = build_get_request( resource_uri=resource_uri, @@ -421,9 +444,9 @@ def get( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -441,7 +464,9 @@ def get( return deserialized - get.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}"} # type: ignore + get.metadata = { + "url": "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -470,8 +495,10 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2018-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_uri=resource_uri, @@ -482,9 +509,9 @@ def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -498,7 +525,9 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}"} # type: ignore + delete.metadata = { + "url": "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}" + } @overload def update( @@ -577,8 +606,8 @@ def update( :type resource_uri: str :param association_name: The name of the diagnostic settings association. Required. :type association_name: str - :param parameters: Parameters supplied to the operation. Is either a model type or a IO type. - Required. + :param parameters: Parameters supplied to the operation. Is either a + GuestDiagnosticSettingsAssociationResourcePatch type or a IO type. Required. :type parameters: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResourcePatch or IO @@ -602,9 +631,11 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.GuestDiagnosticSettingsAssociationResource] + api_version: Literal["2018-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GuestDiagnosticSettingsAssociationResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -626,9 +657,9 @@ def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -646,7 +677,9 @@ def update( return deserialized - update.metadata = {"url": "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}"} # type: ignore + update.metadata = { + "url": "/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}" + } @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.GuestDiagnosticSettingsAssociationResource"]: @@ -662,8 +695,10 @@ def list(self, **kwargs: Any) -> Iterable["_models.GuestDiagnosticSettingsAssoci _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.GuestDiagnosticSettingsAssociationList] + api_version: Literal["2018-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-06-01-preview") + ) + cls: ClsType[_models.GuestDiagnosticSettingsAssociationList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -684,16 +719,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -701,13 +743,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("GuestDiagnosticSettingsAssociationList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -721,7 +763,9 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/guestDiagnosticSettingsAssociations"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/guestDiagnosticSettingsAssociations" + } @distributed_trace def list_by_resource_group( @@ -742,8 +786,10 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.GuestDiagnosticSettingsAssociationList] + api_version: Literal["2018-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-06-01-preview") + ) + cls: ClsType[_models.GuestDiagnosticSettingsAssociationList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -765,16 +811,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -782,13 +835,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("GuestDiagnosticSettingsAssociationList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -802,4 +855,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettingsAssociations"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettingsAssociations" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/operations/_guest_diagnostics_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/operations/_guest_diagnostics_settings_operations.py index af6dd24b1dd1..f829438b7d8c 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/operations/_guest_diagnostics_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/operations/_guest_diagnostics_settings_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -42,8 +47,10 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2018-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -59,7 +66,7 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -78,7 +85,9 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str + api_version: Literal["2018-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-06-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -94,7 +103,7 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -111,8 +120,10 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2018-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -128,7 +139,7 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -147,7 +158,9 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str + api_version: Literal["2018-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-06-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -163,7 +176,7 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -178,7 +191,9 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str + api_version: Literal["2018-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-06-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -189,7 +204,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -204,7 +219,9 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str + api_version: Literal["2018-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-06-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -219,7 +236,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -321,8 +338,8 @@ def create_or_update( :type resource_group_name: str :param diagnostic_settings_name: The name of the diagnostic setting. Required. :type diagnostic_settings_name: str - :param diagnostic_settings: The configuration to create or update. Is either a model type or a - IO type. Required. + :param diagnostic_settings: The configuration to create or update. Is either a + GuestDiagnosticSettingsResource type or a IO type. Required. :type diagnostic_settings: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -344,9 +361,11 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.GuestDiagnosticSettingsResource] + api_version: Literal["2018-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GuestDiagnosticSettingsResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -369,9 +388,9 @@ def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -389,11 +408,13 @@ def create_or_update( deserialized = self._deserialize("GuestDiagnosticSettingsResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}" + } @distributed_trace def get( @@ -422,8 +443,10 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.GuestDiagnosticSettingsResource] + api_version: Literal["2018-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-06-01-preview") + ) + cls: ClsType[_models.GuestDiagnosticSettingsResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -435,9 +458,9 @@ def get( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -455,7 +478,9 @@ def get( return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}" + } @overload def update( @@ -529,7 +554,8 @@ def update( :type resource_group_name: str :param diagnostic_settings_name: The name of the diagnostic setting. Required. :type diagnostic_settings_name: str - :param parameters: The configuration to patch. Is either a model type or a IO type. Required. + :param parameters: The configuration to patch. Is either a GuestDiagnosticSettingsPatchResource + type or a IO type. Required. :type parameters: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsPatchResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -551,9 +577,11 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.GuestDiagnosticSettingsResource] + api_version: Literal["2018-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-06-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.GuestDiagnosticSettingsResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -576,9 +604,9 @@ def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -596,11 +624,13 @@ def update( deserialized = self._deserialize("GuestDiagnosticSettingsResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -629,8 +659,10 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2018-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-06-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -642,9 +674,9 @@ def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -658,7 +690,9 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}" + } @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.GuestDiagnosticSettingsResource"]: @@ -674,8 +708,10 @@ def list(self, **kwargs: Any) -> Iterable["_models.GuestDiagnosticSettingsResour _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.GuestDiagnosticSettingsList] + api_version: Literal["2018-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-06-01-preview") + ) + cls: ClsType[_models.GuestDiagnosticSettingsList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -696,16 +732,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -713,13 +756,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("GuestDiagnosticSettingsList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -733,7 +776,7 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/guestDiagnosticSettings"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/guestDiagnosticSettings"} @distributed_trace def list_by_resource_group( @@ -754,8 +797,10 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.GuestDiagnosticSettingsList] + api_version: Literal["2018-06-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-06-01-preview") + ) + cls: ClsType[_models.GuestDiagnosticSettingsList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -777,16 +822,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -794,13 +846,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("GuestDiagnosticSettingsList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -814,4 +866,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/__init__.py index 8ba4823444a9..2c7733bfd566 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/__init__.py @@ -13,12 +13,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["MonitorManagementClient"] +__all__ = [ + "MonitorManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_configuration.py index 12c7e4de2931..edf7a4b51562 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -36,7 +42,7 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2018-09-01") # type: str + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", "2018-09-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -50,10 +56,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, **kwargs # type: Any - ): - # type: (...) -> None + def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_metadata.json index df2c86ea8327..729ae3d52af8 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_metadata.json @@ -19,13 +19,15 @@ "signature": "credential: \"TokenCredential\",", "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true + "required": true, + "method_location": "positional" }, "subscription_id": { "signature": "subscription_id: str,", "description": "The ID of the target subscription. Required.", "docstring_type": "str", - "required": true + "required": true, + "method_location": "positional" } }, "async": { @@ -48,22 +50,25 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "signature": "api_version: Optional[str]=None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } }, "async": { @@ -71,19 +76,22 @@ "signature": "api_version: Optional[str] = None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { "signature": "profile: KnownProfiles = KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } } } @@ -100,4 +108,4 @@ "action_groups": "ActionGroupsOperations", "baselines": "BaselinesOperations" } -} \ No newline at end of file +} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_monitor_management_client.py index c8ef90ca4885..cebf606564f0 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_monitor_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from . import models +from . import models as _models from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ActionGroupsOperations, BaselinesOperations @@ -52,7 +52,7 @@ def __init__( ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -81,15 +81,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> MonitorManagementClient + def __enter__(self) -> "MonitorManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_vendor.py index 9aad73fc743e..bd0df84f5319 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_vendor.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_vendor.py @@ -5,6 +5,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import List, cast + from azure.core.pipeline.transport import HttpRequest @@ -22,6 +24,7 @@ def _format_url_section(template, **kwargs): try: return template.format(**kwargs) except KeyError as key: - formatted_components = template.split("/") + # Need the cast, as for some reasons "split" is typed as list[str | Any] + formatted_components = cast(List[str], template.split("/")) components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_version.py index ce9ac7ae37b3..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/__init__.py index 8638dc69d869..2c151bb41c19 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/__init__.py @@ -10,12 +10,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["MonitorManagementClient"] +__all__ = [ + "MonitorManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/_configuration.py index d03c5ef67ce5..3fc8bf276302 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -36,7 +42,7 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2018-09-01") # type: str + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", "2018-09-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/_monitor_management_client.py index 54c778e0f4ff..ec68309a91dd 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/_monitor_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from .. import models +from .. import models as _models from ..._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ActionGroupsOperations, BaselinesOperations @@ -53,7 +53,7 @@ def __init__( ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -89,5 +89,5 @@ async def __aenter__(self) -> "MonitorManagementClient": await self._client.__aenter__() return self - async def __aexit__(self, *exc_details) -> None: + async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/__init__.py index 15bdf6da240f..ea540c4b7b93 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/__init__.py @@ -10,7 +10,7 @@ from ._baselines_operations import BaselinesOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/_action_groups_operations.py index 6e2506af5ab4..cfd52d562986 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/_action_groups_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/_action_groups_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -38,6 +39,10 @@ build_update_request, ) +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -132,8 +137,8 @@ async def create_or_update( :type resource_group_name: str :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group: The action group to create or use for the update. Is either a model type - or a IO type. Required. + :param action_group: The action group to create or use for the update. Is either a + ActionGroupResource type or a IO type. Required. :type action_group: ~$(python-base-namespace).v2018_09_01.models.ActionGroupResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -154,9 +159,9 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -179,9 +184,9 @@ async def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -199,11 +204,13 @@ async def create_or_update( deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" + } @distributed_trace_async async def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) -> _models.ActionGroupResource: @@ -230,8 +237,8 @@ async def get(self, resource_group_name: str, action_group_name: str, **kwargs: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -243,9 +250,9 @@ async def get(self, resource_group_name: str, action_group_name: str, **kwargs: params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -263,7 +270,9 @@ async def get(self, resource_group_name: str, action_group_name: str, **kwargs: return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -292,8 +301,8 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -305,9 +314,9 @@ async def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -321,7 +330,9 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" + } @overload async def update( @@ -394,8 +405,8 @@ async def update( :type resource_group_name: str :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Is either a model type or a IO - type. Required. + :param action_group_patch: Parameters supplied to the operation. Is either a + ActionGroupPatchBody type or a IO type. Required. :type action_group_patch: ~$(python-base-namespace).v2018_09_01.models.ActionGroupPatchBody or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -417,9 +428,9 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -442,9 +453,9 @@ async def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -462,7 +473,9 @@ async def update( return deserialized - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" + } @distributed_trace def list_by_subscription_id(self, **kwargs: Any) -> AsyncIterable["_models.ActionGroupResource"]: @@ -477,8 +490,8 @@ def list_by_subscription_id(self, **kwargs: Any) -> AsyncIterable["_models.Actio _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -499,16 +512,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -516,13 +536,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ActionGroupList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -536,7 +556,9 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_subscription_id.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups"} # type: ignore + list_by_subscription_id.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups" + } @distributed_trace def list_by_resource_group( @@ -556,8 +578,8 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -579,16 +601,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -596,13 +625,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ActionGroupList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -616,7 +645,9 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups" + } @overload async def enable_receiver( # pylint: disable=inconsistent-return-statements @@ -692,7 +723,7 @@ async def enable_receiver( # pylint: disable=inconsistent-return-statements :type resource_group_name: str :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param enable_request: The receiver to re-enable. Is either a model type or a IO type. + :param enable_request: The receiver to re-enable. Is either a EnableRequest type or a IO type. Required. :type enable_request: ~$(python-base-namespace).v2018_09_01.models.EnableRequest or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -714,9 +745,9 @@ async def enable_receiver( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -739,9 +770,9 @@ async def enable_receiver( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -755,4 +786,6 @@ async def enable_receiver( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - enable_receiver.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe"} # type: ignore + enable_receiver.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/_baselines_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/_baselines_operations.py index e9e19cd84ab0..d777d05013bb 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/_baselines_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/_baselines_operations.py @@ -7,8 +7,9 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -30,6 +31,10 @@ from ..._vendor import _convert_request from ...operations._baselines_operations import build_list_request +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -115,8 +120,8 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricBaselinesResponse] + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + cls: ClsType[_models.MetricBaselinesResponse] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -145,16 +150,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -162,13 +174,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("MetricBaselinesResponse", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -182,4 +194,4 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/metricBaselines"} # type: ignore + list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/metricBaselines"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/__init__.py index fc2c3eb12f98..b29f7c4a325e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/__init__.py @@ -33,7 +33,7 @@ from ._monitor_management_client_enums import ReceiverStatus from ._monitor_management_client_enums import ResultType from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/_models_py3.py index 511771a35d97..b2bf77ed165d 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/_models_py3.py @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, TYPE_CHECKING, Union +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union from ... import _serialization @@ -32,8 +32,12 @@ class ActionGroupList(_serialization.Model): } def __init__( - self, *, value: Optional[List["_models.ActionGroupResource"]] = None, next_link: Optional[str] = None, **kwargs - ): + self, + *, + value: Optional[List["_models.ActionGroupResource"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: """ :keyword value: The list of action groups. :paramtype value: list[~$(python-base-namespace).v2018_09_01.models.ActionGroupResource] @@ -60,7 +64,7 @@ class ActionGroupPatchBody(_serialization.Model): "enabled": {"key": "properties.enabled", "type": "bool"}, } - def __init__(self, *, tags: Optional[Dict[str, str]] = None, enabled: bool = True, **kwargs): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, enabled: bool = True, **kwargs: Any) -> None: """ :keyword tags: Resource tags. :paramtype tags: dict[str, str] @@ -107,7 +111,7 @@ class Resource(_serialization.Model): "tags": {"key": "tags", "type": "{str}"}, } - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: """ :keyword location: Resource location. Required. :paramtype location: str @@ -222,8 +226,8 @@ def __init__( logic_app_receivers: Optional[List["_models.LogicAppReceiver"]] = None, azure_function_receivers: Optional[List["_models.AzureFunctionReceiver"]] = None, arm_role_receivers: Optional[List["_models.ArmRoleReceiver"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword location: Resource location. Required. :paramtype location: str @@ -304,7 +308,7 @@ class ArmRoleReceiver(_serialization.Model): "role_id": {"key": "roleId", "type": "str"}, } - def __init__(self, *, name: str, role_id: str, **kwargs): + def __init__(self, *, name: str, role_id: str, **kwargs: Any) -> None: """ :keyword name: The name of the arm role receiver. Names must be unique across all receivers within an action group. Required. @@ -362,8 +366,8 @@ def __init__( is_global_runbook: bool, name: Optional[str] = None, service_uri: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword automation_account_id: The Azure automation account Id which holds this runbook and authenticate to Azure resource. Required. @@ -410,7 +414,7 @@ class AzureAppPushReceiver(_serialization.Model): "email_address": {"key": "emailAddress", "type": "str"}, } - def __init__(self, *, name: str, email_address: str, **kwargs): + def __init__(self, *, name: str, email_address: str, **kwargs: Any) -> None: """ :keyword name: The name of the Azure mobile app push receiver. Names must be unique across all receivers within an action group. Required. @@ -454,8 +458,8 @@ class AzureFunctionReceiver(_serialization.Model): } def __init__( - self, *, name: str, function_app_resource_id: str, function_name: str, http_trigger_url: str, **kwargs - ): + self, *, name: str, function_app_resource_id: str, function_name: str, http_trigger_url: str, **kwargs: Any + ) -> None: """ :keyword name: The name of the azure function receiver. Names must be unique across all receivers within an action group. Required. @@ -495,7 +499,7 @@ class BaselineMetadata(_serialization.Model): "value": {"key": "value", "type": "str"}, } - def __init__(self, *, name: str, value: str, **kwargs): + def __init__(self, *, name: str, value: str, **kwargs: Any) -> None: """ :keyword name: Name of the baseline metadata. Required. :paramtype name: str @@ -536,7 +540,7 @@ class EmailReceiver(_serialization.Model): "status": {"key": "status", "type": "str"}, } - def __init__(self, *, name: str, email_address: str, **kwargs): + def __init__(self, *, name: str, email_address: str, **kwargs: Any) -> None: """ :keyword name: The name of the email receiver. Names must be unique across all receivers within an action group. Required. @@ -567,7 +571,7 @@ class EnableRequest(_serialization.Model): "receiver_name": {"key": "receiverName", "type": "str"}, } - def __init__(self, *, receiver_name: str, **kwargs): + def __init__(self, *, receiver_name: str, **kwargs: Any) -> None: """ :keyword receiver_name: The name of the receiver to resubscribe. Required. :paramtype receiver_name: str @@ -590,7 +594,7 @@ class ErrorResponse(_serialization.Model): "message": {"key": "message", "type": "str"}, } - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: """ :keyword code: Error code. :paramtype code: str @@ -641,8 +645,8 @@ class ItsmReceiver(_serialization.Model): } def __init__( - self, *, name: str, workspace_id: str, connection_id: str, ticket_configuration: str, region: str, **kwargs - ): + self, *, name: str, workspace_id: str, connection_id: str, ticket_configuration: str, region: str, **kwargs: Any + ) -> None: """ :keyword name: The name of the Itsm receiver. Names must be unique across all receivers within an action group. Required. @@ -694,7 +698,7 @@ class LogicAppReceiver(_serialization.Model): "callback_url": {"key": "callbackUrl", "type": "str"}, } - def __init__(self, *, name: str, resource_id: str, callback_url: str, **kwargs): + def __init__(self, *, name: str, resource_id: str, callback_url: str, **kwargs: Any) -> None: """ :keyword name: The name of the logic app receiver. Names must be unique across all receivers within an action group. Required. @@ -748,8 +752,8 @@ def __init__( interval: datetime.timedelta, namespace: Optional[str] = None, value: Optional[List["_models.SingleMetricBaseline"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword timespan: The timespan for which the data was retrieved. Its value consists of two datetimes concatenated, separated by '/'. This may be adjusted in the future and returned back @@ -792,7 +796,7 @@ class MetricSingleDimension(_serialization.Model): "value": {"key": "value", "type": "str"}, } - def __init__(self, *, name: str, value: str, **kwargs): + def __init__(self, *, name: str, value: str, **kwargs: Any) -> None: """ :keyword name: Name of the dimension. Required. :paramtype name: str @@ -836,8 +840,8 @@ def __init__( sensitivity: Union[str, "_models.BaselineSensitivity"], low_thresholds: List[float], high_thresholds: List[float], - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword sensitivity: the sensitivity of the baseline. Required. Known values are: "Low", "Medium", and "High". @@ -889,8 +893,8 @@ def __init__( type: str, metric_name: str, baselines: List["_models.TimeSeriesBaseline"], - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword id: The metric baseline Id. Required. :paramtype id: str @@ -941,7 +945,7 @@ class SmsReceiver(_serialization.Model): "status": {"key": "status", "type": "str"}, } - def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs): + def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs: Any) -> None: """ :keyword name: The name of the SMS receiver. Names must be unique across all receivers within an action group. Required. @@ -997,8 +1001,8 @@ def __init__( data: List["_models.SingleBaseline"], dimensions: Optional[List["_models.MetricSingleDimension"]] = None, metadata_values: Optional[List["_models.BaselineMetadata"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword aggregation: The aggregation type of the metric. Required. :paramtype aggregation: str @@ -1045,7 +1049,7 @@ class VoiceReceiver(_serialization.Model): "phone_number": {"key": "phoneNumber", "type": "str"}, } - def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs): + def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs: Any) -> None: """ :keyword name: The name of the voice receiver. Names must be unique across all receivers within an action group. Required. @@ -1083,7 +1087,7 @@ class WebhookReceiver(_serialization.Model): "service_uri": {"key": "serviceUri", "type": "str"}, } - def __init__(self, *, name: str, service_uri: str, **kwargs): + def __init__(self, *, name: str, service_uri: str, **kwargs: Any) -> None: """ :keyword name: The name of the webhook receiver. Names must be unique across all receivers within an action group. Required. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/__init__.py index 15bdf6da240f..ea540c4b7b93 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/__init__.py @@ -10,7 +10,7 @@ from ._baselines_operations import BaselinesOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/_action_groups_operations.py index 8d5dc8688421..54b6a94f09c4 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/_action_groups_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/_action_groups_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -42,8 +47,8 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -59,7 +64,7 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -78,7 +83,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) # type: str + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -94,7 +99,7 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -111,7 +116,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) # type: str + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -127,7 +132,7 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -144,8 +149,8 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -161,7 +166,7 @@ def build_update_request( "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -178,7 +183,7 @@ def build_list_by_subscription_id_request(subscription_id: str, **kwargs: Any) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) # type: str + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -187,7 +192,7 @@ def build_list_by_subscription_id_request(subscription_id: str, **kwargs: Any) - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -202,7 +207,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) # type: str + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -217,7 +222,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -234,8 +239,8 @@ def build_enable_receiver_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -251,7 +256,7 @@ def build_enable_receiver_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -354,8 +359,8 @@ def create_or_update( :type resource_group_name: str :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group: The action group to create or use for the update. Is either a model type - or a IO type. Required. + :param action_group: The action group to create or use for the update. Is either a + ActionGroupResource type or a IO type. Required. :type action_group: ~$(python-base-namespace).v2018_09_01.models.ActionGroupResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -376,9 +381,9 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -401,9 +406,9 @@ def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -421,11 +426,13 @@ def create_or_update( deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" + } @distributed_trace def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) -> _models.ActionGroupResource: @@ -452,8 +459,8 @@ def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) - _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -465,9 +472,9 @@ def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) - params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -485,7 +492,9 @@ def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) - return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -514,8 +523,8 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -527,9 +536,9 @@ def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -543,7 +552,9 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" + } @overload def update( @@ -616,8 +627,8 @@ def update( :type resource_group_name: str :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Is either a model type or a IO - type. Required. + :param action_group_patch: Parameters supplied to the operation. Is either a + ActionGroupPatchBody type or a IO type. Required. :type action_group_patch: ~$(python-base-namespace).v2018_09_01.models.ActionGroupPatchBody or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -639,9 +650,9 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -664,9 +675,9 @@ def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -684,7 +695,9 @@ def update( return deserialized - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" + } @distributed_trace def list_by_subscription_id(self, **kwargs: Any) -> Iterable["_models.ActionGroupResource"]: @@ -699,8 +712,8 @@ def list_by_subscription_id(self, **kwargs: Any) -> Iterable["_models.ActionGrou _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -721,16 +734,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -738,13 +758,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ActionGroupList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -758,7 +778,9 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_subscription_id.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups"} # type: ignore + list_by_subscription_id.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups" + } @distributed_trace def list_by_resource_group( @@ -778,8 +800,8 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -801,16 +823,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -818,13 +847,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ActionGroupList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -838,7 +867,9 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups" + } @overload def enable_receiver( # pylint: disable=inconsistent-return-statements @@ -914,7 +945,7 @@ def enable_receiver( # pylint: disable=inconsistent-return-statements :type resource_group_name: str :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param enable_request: The receiver to re-enable. Is either a model type or a IO type. + :param enable_request: The receiver to re-enable. Is either a EnableRequest type or a IO type. Required. :type enable_request: ~$(python-base-namespace).v2018_09_01.models.EnableRequest or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -936,9 +967,9 @@ def enable_receiver( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -961,9 +992,9 @@ def enable_receiver( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -977,4 +1008,6 @@ def enable_receiver( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - enable_receiver.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe"} # type: ignore + enable_receiver.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/_baselines_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/_baselines_operations.py index 041315649878..95594415c9f5 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/_baselines_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/_baselines_operations.py @@ -7,8 +7,9 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -30,6 +31,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -53,7 +58,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) # type: str + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -62,7 +67,7 @@ def build_list_request( "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters if metricnames is not None: @@ -170,8 +175,8 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricBaselinesResponse] + api_version: Literal["2018-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) + cls: ClsType[_models.MetricBaselinesResponse] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -200,16 +205,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -217,13 +229,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("MetricBaselinesResponse", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -237,4 +249,4 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/metricBaselines"} # type: ignore + list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/metricBaselines"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/__init__.py index 8ba4823444a9..2c7733bfd566 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/__init__.py @@ -13,12 +13,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["MonitorManagementClient"] +__all__ = [ + "MonitorManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_configuration.py index acbc54026c7d..f6d57eb37c8c 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -34,7 +40,7 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2018-11-27-preview") # type: str + api_version: Literal["2018-11-27-preview"] = kwargs.pop("api_version", "2018-11-27-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -45,10 +51,7 @@ def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, **kwargs # type: Any - ): - # type: (...) -> None + def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_metadata.json index 0bbb96d82593..5c87c2239967 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_metadata.json @@ -19,7 +19,8 @@ "signature": "credential: \"TokenCredential\",", "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true + "required": true, + "method_location": "positional" } }, "async": { @@ -36,22 +37,25 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "signature": "api_version: Optional[str]=None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } }, "async": { @@ -59,19 +63,22 @@ "signature": "api_version: Optional[str] = None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { "signature": "profile: KnownProfiles = KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } } } @@ -87,4 +94,4 @@ "operation_groups": { "vm_insights": "VMInsightsOperations" } -} \ No newline at end of file +} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_monitor_management_client.py index 83cbac7247fa..029ffea63130 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_monitor_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from . import models +from . import models as _models from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import VMInsightsOperations @@ -43,7 +43,7 @@ def __init__( self._config = MonitorManagementClientConfiguration(credential=credential, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -71,15 +71,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> MonitorManagementClient + def __enter__(self) -> "MonitorManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_vendor.py index 9aad73fc743e..bd0df84f5319 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_vendor.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_vendor.py @@ -5,6 +5,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import List, cast + from azure.core.pipeline.transport import HttpRequest @@ -22,6 +24,7 @@ def _format_url_section(template, **kwargs): try: return template.format(**kwargs) except KeyError as key: - formatted_components = template.split("/") + # Need the cast, as for some reasons "split" is typed as list[str | Any] + formatted_components = cast(List[str], template.split("/")) components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_version.py index ce9ac7ae37b3..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/__init__.py index 8638dc69d869..2c151bb41c19 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/__init__.py @@ -10,12 +10,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["MonitorManagementClient"] +__all__ = [ + "MonitorManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/_configuration.py index 14c0bea3671f..f873a5ef6cdb 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -34,7 +40,7 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2018-11-27-preview") # type: str + api_version: Literal["2018-11-27-preview"] = kwargs.pop("api_version", "2018-11-27-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/_monitor_management_client.py index 19eea0780dee..06590e1109e1 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/_monitor_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from .. import models +from .. import models as _models from ..._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import VMInsightsOperations @@ -43,7 +43,7 @@ def __init__( self._config = MonitorManagementClientConfiguration(credential=credential, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -78,5 +78,5 @@ async def __aenter__(self) -> "MonitorManagementClient": await self._client.__aenter__() return self - async def __aexit__(self, *exc_details) -> None: + async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/operations/__init__.py index c49e28cd308f..d1c0fc736fe2 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/operations/__init__.py @@ -9,7 +9,7 @@ from ._vm_insights_operations import VMInsightsOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/operations/_vm_insights_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/operations/_vm_insights_operations.py index a844dea9ce5c..c92197ab0526 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/operations/_vm_insights_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/operations/_vm_insights_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -27,6 +28,10 @@ from ..._vendor import _convert_request from ...operations._vm_insights_operations import build_get_onboarding_status_request +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -73,8 +78,10 @@ async def get_onboarding_status(self, resource_uri: str, **kwargs: Any) -> _mode _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-27-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.VMInsightsOnboardingStatus] + api_version: Literal["2018-11-27-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-11-27-preview") + ) + cls: ClsType[_models.VMInsightsOnboardingStatus] = kwargs.pop("cls", None) request = build_get_onboarding_status_request( resource_uri=resource_uri, @@ -84,9 +91,9 @@ async def get_onboarding_status(self, resource_uri: str, **kwargs: Any) -> _mode params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -104,4 +111,6 @@ async def get_onboarding_status(self, resource_uri: str, **kwargs: Any) -> _mode return deserialized - get_onboarding_status.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/vmInsightsOnboardingStatuses/default"} # type: ignore + get_onboarding_status.metadata = { + "url": "/{resourceUri}/providers/Microsoft.Insights/vmInsightsOnboardingStatuses/default" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/__init__.py index c43be904632c..1e469b651214 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/__init__.py @@ -16,7 +16,7 @@ from ._monitor_management_client_enums import DataStatus from ._monitor_management_client_enums import OnboardingStatus from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/_models_py3.py index bf881bf182e5..0fb4da2b30d1 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/_models_py3.py @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, Optional, TYPE_CHECKING, Union +from typing import Any, List, Optional, TYPE_CHECKING, Union from ... import _serialization @@ -33,7 +33,7 @@ class DataContainer(_serialization.Model): "workspace": {"key": "workspace", "type": "WorkspaceInfo"}, } - def __init__(self, *, workspace: "_models.WorkspaceInfo", **kwargs): + def __init__(self, *, workspace: "_models.WorkspaceInfo", **kwargs: Any) -> None: """ :keyword workspace: Log Analytics workspace information. Required. :paramtype workspace: ~$(python-base-namespace).v2018_11_27_preview.models.WorkspaceInfo @@ -62,7 +62,7 @@ class Error(_serialization.Model): "message": {"key": "message", "type": "str"}, } - def __init__(self, *, code: str, message: Optional[str] = None, **kwargs): + def __init__(self, *, code: str, message: Optional[str] = None, **kwargs: Any) -> None: """ :keyword code: Error code identifying the specific error. Required. :paramtype code: str @@ -99,7 +99,7 @@ class ProxyResource(_serialization.Model): "type": {"key": "type", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.id = None @@ -124,7 +124,7 @@ class ResponseWithError(_serialization.Model): "error": {"key": "error", "type": "Error"}, } - def __init__(self, *, error: "_models.Error", **kwargs): + def __init__(self, *, error: "_models.Error", **kwargs: Any) -> None: """ :keyword error: Error information. Required. :paramtype error: ~$(python-base-namespace).v2018_11_27_preview.models.Error @@ -183,8 +183,8 @@ def __init__( onboarding_status: Optional[Union[str, "_models.OnboardingStatus"]] = None, data_status: Optional[Union[str, "_models.DataStatus"]] = None, data: Optional[List["_models.DataContainer"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword resource_id: Azure Resource Manager identifier of the resource whose onboarding status is being represented. @@ -233,7 +233,9 @@ class WorkspaceInfo(_serialization.Model): "customer_id": {"key": "properties.customerId", "type": "str"}, } - def __init__(self, *, id: str, location: str, customer_id: str, **kwargs): # pylint: disable=redefined-builtin + def __init__( + self, *, id: str, location: str, customer_id: str, **kwargs: Any # pylint: disable=redefined-builtin + ) -> None: """ :keyword id: Azure Resource Manager identifier of the Log Analytics Workspace. Required. :paramtype id: str diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/operations/__init__.py index c49e28cd308f..d1c0fc736fe2 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/operations/__init__.py @@ -9,7 +9,7 @@ from ._vm_insights_operations import VMInsightsOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/operations/_vm_insights_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/operations/_vm_insights_operations.py index e815b2366955..60fc94fc2db8 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/operations/_vm_insights_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/operations/_vm_insights_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -27,6 +28,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -38,7 +43,9 @@ def build_get_onboarding_status_request(resource_uri: str, **kwargs: Any) -> Htt _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-27-preview")) # type: str + api_version: Literal["2018-11-27-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-11-27-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -49,7 +56,7 @@ def build_get_onboarding_status_request(resource_uri: str, **kwargs: Any) -> Htt "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -102,8 +109,10 @@ def get_onboarding_status(self, resource_uri: str, **kwargs: Any) -> _models.VMI _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-27-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.VMInsightsOnboardingStatus] + api_version: Literal["2018-11-27-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2018-11-27-preview") + ) + cls: ClsType[_models.VMInsightsOnboardingStatus] = kwargs.pop("cls", None) request = build_get_onboarding_status_request( resource_uri=resource_uri, @@ -113,9 +122,9 @@ def get_onboarding_status(self, resource_uri: str, **kwargs: Any) -> _models.VMI params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -133,4 +142,6 @@ def get_onboarding_status(self, resource_uri: str, **kwargs: Any) -> _models.VMI return deserialized - get_onboarding_status.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/vmInsightsOnboardingStatuses/default"} # type: ignore + get_onboarding_status.metadata = { + "url": "/{resourceUri}/providers/Microsoft.Insights/vmInsightsOnboardingStatuses/default" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/__init__.py index 8ba4823444a9..2c7733bfd566 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/__init__.py @@ -13,12 +13,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["MonitorManagementClient"] +__all__ = [ + "MonitorManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_configuration.py index 8d2286410a6a..ed8c0533d9be 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -36,7 +42,7 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2019-03-01") # type: str + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", "2019-03-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -50,10 +56,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, **kwargs # type: Any - ): - # type: (...) -> None + def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_metadata.json index 38479b2f6c2b..59e413fdad82 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_metadata.json @@ -19,13 +19,15 @@ "signature": "credential: \"TokenCredential\",", "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true + "required": true, + "method_location": "positional" }, "subscription_id": { "signature": "subscription_id: str,", "description": "The ID of the target subscription. Required.", "docstring_type": "str", - "required": true + "required": true, + "method_location": "positional" } }, "async": { @@ -48,22 +50,25 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "signature": "api_version: Optional[str]=None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } }, "async": { @@ -71,19 +76,22 @@ "signature": "api_version: Optional[str] = None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { "signature": "profile: KnownProfiles = KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } } } @@ -100,4 +108,4 @@ "action_groups": "ActionGroupsOperations", "baselines": "BaselinesOperations" } -} \ No newline at end of file +} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_monitor_management_client.py index f6196670f808..4129fbf74b4c 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_monitor_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from . import models +from . import models as _models from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ActionGroupsOperations, BaselinesOperations @@ -52,7 +52,7 @@ def __init__( ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -81,15 +81,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> MonitorManagementClient + def __enter__(self) -> "MonitorManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_vendor.py index 9aad73fc743e..bd0df84f5319 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_vendor.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_vendor.py @@ -5,6 +5,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import List, cast + from azure.core.pipeline.transport import HttpRequest @@ -22,6 +24,7 @@ def _format_url_section(template, **kwargs): try: return template.format(**kwargs) except KeyError as key: - formatted_components = template.split("/") + # Need the cast, as for some reasons "split" is typed as list[str | Any] + formatted_components = cast(List[str], template.split("/")) components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_version.py index ce9ac7ae37b3..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/__init__.py index 8638dc69d869..2c151bb41c19 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/__init__.py @@ -10,12 +10,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["MonitorManagementClient"] +__all__ = [ + "MonitorManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/_configuration.py index d02e2a974c4d..22f44870cc99 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -36,7 +42,7 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2019-03-01") # type: str + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", "2019-03-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/_monitor_management_client.py index 10552ea91e3b..668e5db628f1 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/_monitor_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from .. import models +from .. import models as _models from ..._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ActionGroupsOperations, BaselinesOperations @@ -53,7 +53,7 @@ def __init__( ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -89,5 +89,5 @@ async def __aenter__(self) -> "MonitorManagementClient": await self._client.__aenter__() return self - async def __aexit__(self, *exc_details) -> None: + async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/operations/__init__.py index 15bdf6da240f..ea540c4b7b93 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/operations/__init__.py @@ -10,7 +10,7 @@ from ._baselines_operations import BaselinesOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/operations/_action_groups_operations.py index 7ed1f56a91c9..24a1bce65d8a 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/operations/_action_groups_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/operations/_action_groups_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -38,6 +39,10 @@ build_update_request, ) +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -132,8 +137,8 @@ async def create_or_update( :type resource_group_name: str :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group: The action group to create or use for the update. Is either a model type - or a IO type. Required. + :param action_group: The action group to create or use for the update. Is either a + ActionGroupResource type or a IO type. Required. :type action_group: ~$(python-base-namespace).v2019_03_01.models.ActionGroupResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -154,9 +159,9 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -179,9 +184,9 @@ async def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -199,11 +204,13 @@ async def create_or_update( deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" + } @distributed_trace_async async def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) -> _models.ActionGroupResource: @@ -230,8 +237,8 @@ async def get(self, resource_group_name: str, action_group_name: str, **kwargs: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -243,9 +250,9 @@ async def get(self, resource_group_name: str, action_group_name: str, **kwargs: params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -263,7 +270,9 @@ async def get(self, resource_group_name: str, action_group_name: str, **kwargs: return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -292,8 +301,8 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -305,9 +314,9 @@ async def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -321,7 +330,9 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" + } @overload async def update( @@ -394,8 +405,8 @@ async def update( :type resource_group_name: str :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Is either a model type or a IO - type. Required. + :param action_group_patch: Parameters supplied to the operation. Is either a + ActionGroupPatchBody type or a IO type. Required. :type action_group_patch: ~$(python-base-namespace).v2019_03_01.models.ActionGroupPatchBody or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -417,9 +428,9 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -442,9 +453,9 @@ async def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -462,7 +473,9 @@ async def update( return deserialized - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" + } @distributed_trace def list_by_subscription_id(self, **kwargs: Any) -> AsyncIterable["_models.ActionGroupResource"]: @@ -477,8 +490,8 @@ def list_by_subscription_id(self, **kwargs: Any) -> AsyncIterable["_models.Actio _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -499,16 +512,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -516,13 +536,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ActionGroupList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -536,7 +556,9 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_subscription_id.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups"} # type: ignore + list_by_subscription_id.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups" + } @distributed_trace def list_by_resource_group( @@ -556,8 +578,8 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -579,16 +601,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -596,13 +625,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ActionGroupList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -616,7 +645,9 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups" + } @overload async def enable_receiver( # pylint: disable=inconsistent-return-statements @@ -692,7 +723,7 @@ async def enable_receiver( # pylint: disable=inconsistent-return-statements :type resource_group_name: str :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param enable_request: The receiver to re-enable. Is either a model type or a IO type. + :param enable_request: The receiver to re-enable. Is either a EnableRequest type or a IO type. Required. :type enable_request: ~$(python-base-namespace).v2019_03_01.models.EnableRequest or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -714,9 +745,9 @@ async def enable_receiver( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -739,9 +770,9 @@ async def enable_receiver( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -755,4 +786,6 @@ async def enable_receiver( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - enable_receiver.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe"} # type: ignore + enable_receiver.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/operations/_baselines_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/operations/_baselines_operations.py index e17756c0535c..077016fb4b61 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/operations/_baselines_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/operations/_baselines_operations.py @@ -7,8 +7,9 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -30,6 +31,10 @@ from ..._vendor import _convert_request from ...operations._baselines_operations import build_list_request +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -115,8 +120,8 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricBaselinesResponse] + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.MetricBaselinesResponse] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -145,16 +150,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -162,13 +174,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("MetricBaselinesResponse", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -182,4 +194,4 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/metricBaselines"} # type: ignore + list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/metricBaselines"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/__init__.py index 6020f789616f..a5d67150b91c 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/__init__.py @@ -33,7 +33,7 @@ from ._monitor_management_client_enums import ReceiverStatus from ._monitor_management_client_enums import ResultType from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/_models_py3.py index 051dbc824eae..a79714ab451a 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/_models_py3.py @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, TYPE_CHECKING, Union +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union from ... import _serialization @@ -32,8 +32,12 @@ class ActionGroupList(_serialization.Model): } def __init__( - self, *, value: Optional[List["_models.ActionGroupResource"]] = None, next_link: Optional[str] = None, **kwargs - ): + self, + *, + value: Optional[List["_models.ActionGroupResource"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: """ :keyword value: The list of action groups. :paramtype value: list[~$(python-base-namespace).v2019_03_01.models.ActionGroupResource] @@ -60,7 +64,7 @@ class ActionGroupPatchBody(_serialization.Model): "enabled": {"key": "properties.enabled", "type": "bool"}, } - def __init__(self, *, tags: Optional[Dict[str, str]] = None, enabled: bool = True, **kwargs): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, enabled: bool = True, **kwargs: Any) -> None: """ :keyword tags: Resource tags. :paramtype tags: dict[str, str] @@ -107,7 +111,7 @@ class AzureResource(_serialization.Model): "tags": {"key": "tags", "type": "{str}"}, } - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: """ :keyword location: Resource location. Required. :paramtype location: str @@ -222,8 +226,8 @@ def __init__( logic_app_receivers: Optional[List["_models.LogicAppReceiver"]] = None, azure_function_receivers: Optional[List["_models.AzureFunctionReceiver"]] = None, arm_role_receivers: Optional[List["_models.ArmRoleReceiver"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword location: Resource location. Required. :paramtype location: str @@ -307,7 +311,7 @@ class ArmRoleReceiver(_serialization.Model): "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, } - def __init__(self, *, name: str, role_id: str, use_common_alert_schema: bool = False, **kwargs): + def __init__(self, *, name: str, role_id: str, use_common_alert_schema: bool = False, **kwargs: Any) -> None: """ :keyword name: The name of the arm role receiver. Names must be unique across all receivers within an action group. Required. @@ -372,8 +376,8 @@ def __init__( name: Optional[str] = None, service_uri: Optional[str] = None, use_common_alert_schema: bool = False, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword automation_account_id: The Azure automation account Id which holds this runbook and authenticate to Azure resource. Required. @@ -423,7 +427,7 @@ class AzureAppPushReceiver(_serialization.Model): "email_address": {"key": "emailAddress", "type": "str"}, } - def __init__(self, *, name: str, email_address: str, **kwargs): + def __init__(self, *, name: str, email_address: str, **kwargs: Any) -> None: """ :keyword name: The name of the Azure mobile app push receiver. Names must be unique across all receivers within an action group. Required. @@ -477,8 +481,8 @@ def __init__( function_name: str, http_trigger_url: str, use_common_alert_schema: bool = False, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: The name of the azure function receiver. Names must be unique across all receivers within an action group. Required. @@ -521,7 +525,7 @@ class BaselineMetadata(_serialization.Model): "value": {"key": "value", "type": "str"}, } - def __init__(self, *, name: str, value: str, **kwargs): + def __init__(self, *, name: str, value: str, **kwargs: Any) -> None: """ :keyword name: Name of the baseline metadata. Required. :paramtype name: str @@ -565,7 +569,7 @@ class EmailReceiver(_serialization.Model): "status": {"key": "status", "type": "str"}, } - def __init__(self, *, name: str, email_address: str, use_common_alert_schema: bool = False, **kwargs): + def __init__(self, *, name: str, email_address: str, use_common_alert_schema: bool = False, **kwargs: Any) -> None: """ :keyword name: The name of the email receiver. Names must be unique across all receivers within an action group. Required. @@ -599,7 +603,7 @@ class EnableRequest(_serialization.Model): "receiver_name": {"key": "receiverName", "type": "str"}, } - def __init__(self, *, receiver_name: str, **kwargs): + def __init__(self, *, receiver_name: str, **kwargs: Any) -> None: """ :keyword receiver_name: The name of the receiver to resubscribe. Required. :paramtype receiver_name: str @@ -622,7 +626,7 @@ class ErrorResponse(_serialization.Model): "message": {"key": "message", "type": "str"}, } - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: """ :keyword code: Error code. :paramtype code: str @@ -673,8 +677,8 @@ class ItsmReceiver(_serialization.Model): } def __init__( - self, *, name: str, workspace_id: str, connection_id: str, ticket_configuration: str, region: str, **kwargs - ): + self, *, name: str, workspace_id: str, connection_id: str, ticket_configuration: str, region: str, **kwargs: Any + ) -> None: """ :keyword name: The name of the Itsm receiver. Names must be unique across all receivers within an action group. Required. @@ -730,8 +734,8 @@ class LogicAppReceiver(_serialization.Model): } def __init__( - self, *, name: str, resource_id: str, callback_url: str, use_common_alert_schema: bool = False, **kwargs - ): + self, *, name: str, resource_id: str, callback_url: str, use_common_alert_schema: bool = False, **kwargs: Any + ) -> None: """ :keyword name: The name of the logic app receiver. Names must be unique across all receivers within an action group. Required. @@ -761,7 +765,7 @@ class MetricBaselinesResponse(_serialization.Model): "value": {"key": "value", "type": "[SingleMetricBaseline]"}, } - def __init__(self, *, value: Optional[List["_models.SingleMetricBaseline"]] = None, **kwargs): + def __init__(self, *, value: Optional[List["_models.SingleMetricBaseline"]] = None, **kwargs: Any) -> None: """ :keyword value: The list of metric baselines. :paramtype value: list[~$(python-base-namespace).v2019_03_01.models.SingleMetricBaseline] @@ -791,7 +795,7 @@ class MetricSingleDimension(_serialization.Model): "value": {"key": "value", "type": "str"}, } - def __init__(self, *, name: str, value: str, **kwargs): + def __init__(self, *, name: str, value: str, **kwargs: Any) -> None: """ :keyword name: Name of the dimension. Required. :paramtype name: str @@ -835,8 +839,8 @@ def __init__( sensitivity: Union[str, "_models.BaselineSensitivity"], low_thresholds: List[float], high_thresholds: List[float], - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword sensitivity: the sensitivity of the baseline. Required. Known values are: "Low", "Medium", and "High". @@ -906,8 +910,8 @@ def __init__( interval: datetime.timedelta, baselines: List["_models.TimeSeriesBaseline"], namespace: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword id: The metric baseline Id. Required. :paramtype id: str @@ -971,7 +975,7 @@ class SmsReceiver(_serialization.Model): "status": {"key": "status", "type": "str"}, } - def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs): + def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs: Any) -> None: """ :keyword name: The name of the SMS receiver. Names must be unique across all receivers within an action group. Required. @@ -1027,8 +1031,8 @@ def __init__( data: List["_models.SingleBaseline"], dimensions: Optional[List["_models.MetricSingleDimension"]] = None, metadata_values: Optional[List["_models.BaselineMetadata"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword aggregation: The aggregation type of the metric. Required. :paramtype aggregation: str @@ -1075,7 +1079,7 @@ class VoiceReceiver(_serialization.Model): "phone_number": {"key": "phoneNumber", "type": "str"}, } - def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs): + def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs: Any) -> None: """ :keyword name: The name of the voice receiver. Names must be unique across all receivers within an action group. Required. @@ -1116,7 +1120,7 @@ class WebhookReceiver(_serialization.Model): "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, } - def __init__(self, *, name: str, service_uri: str, use_common_alert_schema: bool = False, **kwargs): + def __init__(self, *, name: str, service_uri: str, use_common_alert_schema: bool = False, **kwargs: Any) -> None: """ :keyword name: The name of the webhook receiver. Names must be unique across all receivers within an action group. Required. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/operations/__init__.py index 15bdf6da240f..ea540c4b7b93 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/operations/__init__.py @@ -10,7 +10,7 @@ from ._baselines_operations import BaselinesOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/operations/_action_groups_operations.py index 1089f724a760..5b2d52ea5e8c 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/operations/_action_groups_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/operations/_action_groups_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -42,8 +47,8 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -59,7 +64,7 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -78,7 +83,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -94,7 +99,7 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -111,7 +116,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -127,7 +132,7 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -144,8 +149,8 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -161,7 +166,7 @@ def build_update_request( "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -178,7 +183,7 @@ def build_list_by_subscription_id_request(subscription_id: str, **kwargs: Any) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -187,7 +192,7 @@ def build_list_by_subscription_id_request(subscription_id: str, **kwargs: Any) - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -202,7 +207,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -217,7 +222,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -234,8 +239,8 @@ def build_enable_receiver_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -251,7 +256,7 @@ def build_enable_receiver_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -354,8 +359,8 @@ def create_or_update( :type resource_group_name: str :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group: The action group to create or use for the update. Is either a model type - or a IO type. Required. + :param action_group: The action group to create or use for the update. Is either a + ActionGroupResource type or a IO type. Required. :type action_group: ~$(python-base-namespace).v2019_03_01.models.ActionGroupResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -376,9 +381,9 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -401,9 +406,9 @@ def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -421,11 +426,13 @@ def create_or_update( deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" + } @distributed_trace def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) -> _models.ActionGroupResource: @@ -452,8 +459,8 @@ def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) - _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -465,9 +472,9 @@ def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) - params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -485,7 +492,9 @@ def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) - return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -514,8 +523,8 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -527,9 +536,9 @@ def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -543,7 +552,9 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" + } @overload def update( @@ -616,8 +627,8 @@ def update( :type resource_group_name: str :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Is either a model type or a IO - type. Required. + :param action_group_patch: Parameters supplied to the operation. Is either a + ActionGroupPatchBody type or a IO type. Required. :type action_group_patch: ~$(python-base-namespace).v2019_03_01.models.ActionGroupPatchBody or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -639,9 +650,9 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -664,9 +675,9 @@ def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -684,7 +695,9 @@ def update( return deserialized - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" + } @distributed_trace def list_by_subscription_id(self, **kwargs: Any) -> Iterable["_models.ActionGroupResource"]: @@ -699,8 +712,8 @@ def list_by_subscription_id(self, **kwargs: Any) -> Iterable["_models.ActionGrou _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -721,16 +734,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -738,13 +758,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ActionGroupList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -758,7 +778,9 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_subscription_id.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups"} # type: ignore + list_by_subscription_id.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups" + } @distributed_trace def list_by_resource_group( @@ -778,8 +800,8 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -801,16 +823,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -818,13 +847,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ActionGroupList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -838,7 +867,9 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups" + } @overload def enable_receiver( # pylint: disable=inconsistent-return-statements @@ -914,7 +945,7 @@ def enable_receiver( # pylint: disable=inconsistent-return-statements :type resource_group_name: str :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param enable_request: The receiver to re-enable. Is either a model type or a IO type. + :param enable_request: The receiver to re-enable. Is either a EnableRequest type or a IO type. Required. :type enable_request: ~$(python-base-namespace).v2019_03_01.models.EnableRequest or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -936,9 +967,9 @@ def enable_receiver( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -961,9 +992,9 @@ def enable_receiver( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -977,4 +1008,6 @@ def enable_receiver( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - enable_receiver.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe"} # type: ignore + enable_receiver.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/operations/_baselines_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/operations/_baselines_operations.py index 92a25366ae7d..f00aae59fc6d 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/operations/_baselines_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/operations/_baselines_operations.py @@ -7,8 +7,9 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -30,6 +31,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -53,7 +58,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -62,7 +67,7 @@ def build_list_request( "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters if metricnames is not None: @@ -170,8 +175,8 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.MetricBaselinesResponse] + api_version: Literal["2019-03-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-03-01")) + cls: ClsType[_models.MetricBaselinesResponse] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -200,16 +205,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -217,13 +229,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("MetricBaselinesResponse", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -237,4 +249,4 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/metricBaselines"} # type: ignore + list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/metricBaselines"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/__init__.py index 8ba4823444a9..2c7733bfd566 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/__init__.py @@ -13,12 +13,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["MonitorManagementClient"] +__all__ = [ + "MonitorManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_configuration.py index f2b5ee16ad38..8839954d182d 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -36,7 +42,7 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2019-06-01") # type: str + api_version: Literal["2019-06-01"] = kwargs.pop("api_version", "2019-06-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -50,10 +56,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, **kwargs # type: Any - ): - # type: (...) -> None + def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_metadata.json index e7dc2ce80858..662a3ad580f2 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_metadata.json @@ -19,13 +19,15 @@ "signature": "credential: \"TokenCredential\",", "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true + "required": true, + "method_location": "positional" }, "subscription_id": { "signature": "subscription_id: str,", "description": "The ID of the target subscription. Required.", "docstring_type": "str", - "required": true + "required": true, + "method_location": "positional" } }, "async": { @@ -48,22 +50,25 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "signature": "api_version: Optional[str]=None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } }, "async": { @@ -71,19 +76,22 @@ "signature": "api_version: Optional[str] = None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { "signature": "profile: KnownProfiles = KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } } } @@ -99,4 +107,4 @@ "operation_groups": { "action_groups": "ActionGroupsOperations" } -} \ No newline at end of file +} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_monitor_management_client.py index 166d1376bae4..81c81dd57f31 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_monitor_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from . import models +from . import models as _models from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ActionGroupsOperations @@ -50,7 +50,7 @@ def __init__( ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -78,15 +78,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> MonitorManagementClient + def __enter__(self) -> "MonitorManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_vendor.py index 9aad73fc743e..bd0df84f5319 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_vendor.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_vendor.py @@ -5,6 +5,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import List, cast + from azure.core.pipeline.transport import HttpRequest @@ -22,6 +24,7 @@ def _format_url_section(template, **kwargs): try: return template.format(**kwargs) except KeyError as key: - formatted_components = template.split("/") + # Need the cast, as for some reasons "split" is typed as list[str | Any] + formatted_components = cast(List[str], template.split("/")) components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_version.py index ce9ac7ae37b3..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/__init__.py index 8638dc69d869..2c151bb41c19 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/__init__.py @@ -10,12 +10,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["MonitorManagementClient"] +__all__ = [ + "MonitorManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/_configuration.py index 93b0e6be8e61..43ad73d857c9 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -36,7 +42,7 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2019-06-01") # type: str + api_version: Literal["2019-06-01"] = kwargs.pop("api_version", "2019-06-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/_monitor_management_client.py index a6e3a27ecf96..5ea459378546 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/_monitor_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from .. import models +from .. import models as _models from ..._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ActionGroupsOperations @@ -51,7 +51,7 @@ def __init__( ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -86,5 +86,5 @@ async def __aenter__(self) -> "MonitorManagementClient": await self._client.__aenter__() return self - async def __aexit__(self, *exc_details) -> None: + async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/operations/__init__.py index 0e396f5d7fb0..05f0527dc979 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/operations/__init__.py @@ -9,7 +9,7 @@ from ._action_groups_operations import ActionGroupsOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/operations/_action_groups_operations.py index f2e8d1087df8..90e22e4bd3fc 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/operations/_action_groups_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/operations/_action_groups_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -38,6 +39,10 @@ build_update_request, ) +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -132,8 +137,8 @@ async def create_or_update( :type resource_group_name: str :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group: The action group to create or use for the update. Is either a model type - or a IO type. Required. + :param action_group: The action group to create or use for the update. Is either a + ActionGroupResource type or a IO type. Required. :type action_group: ~$(python-base-namespace).v2019_06_01.models.ActionGroupResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -154,9 +159,9 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] + api_version: Literal["2019-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -179,9 +184,9 @@ async def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -199,11 +204,13 @@ async def create_or_update( deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" + } @distributed_trace_async async def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) -> _models.ActionGroupResource: @@ -230,8 +237,8 @@ async def get(self, resource_group_name: str, action_group_name: str, **kwargs: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] + api_version: Literal["2019-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) + cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -243,9 +250,9 @@ async def get(self, resource_group_name: str, action_group_name: str, **kwargs: params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -263,7 +270,9 @@ async def get(self, resource_group_name: str, action_group_name: str, **kwargs: return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -292,8 +301,8 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2019-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -305,9 +314,9 @@ async def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -321,7 +330,9 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" + } @overload async def update( @@ -394,8 +405,8 @@ async def update( :type resource_group_name: str :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Is either a model type or a IO - type. Required. + :param action_group_patch: Parameters supplied to the operation. Is either a + ActionGroupPatchBody type or a IO type. Required. :type action_group_patch: ~$(python-base-namespace).v2019_06_01.models.ActionGroupPatchBody or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -417,9 +428,9 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] + api_version: Literal["2019-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -442,9 +453,9 @@ async def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -462,7 +473,9 @@ async def update( return deserialized - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" + } @distributed_trace def list_by_subscription_id(self, **kwargs: Any) -> AsyncIterable["_models.ActionGroupResource"]: @@ -477,8 +490,8 @@ def list_by_subscription_id(self, **kwargs: Any) -> AsyncIterable["_models.Actio _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + api_version: Literal["2019-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) + cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -499,16 +512,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -516,13 +536,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ActionGroupList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -536,7 +556,9 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_subscription_id.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups"} # type: ignore + list_by_subscription_id.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups" + } @distributed_trace def list_by_resource_group( @@ -556,8 +578,8 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + api_version: Literal["2019-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) + cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -579,16 +601,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -596,13 +625,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ActionGroupList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -616,7 +645,9 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups" + } @overload async def enable_receiver( # pylint: disable=inconsistent-return-statements @@ -692,7 +723,7 @@ async def enable_receiver( # pylint: disable=inconsistent-return-statements :type resource_group_name: str :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param enable_request: The receiver to re-enable. Is either a model type or a IO type. + :param enable_request: The receiver to re-enable. Is either a EnableRequest type or a IO type. Required. :type enable_request: ~$(python-base-namespace).v2019_06_01.models.EnableRequest or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -714,9 +745,9 @@ async def enable_receiver( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2019-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -739,9 +770,9 @@ async def enable_receiver( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -755,4 +786,6 @@ async def enable_receiver( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - enable_receiver.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe"} # type: ignore + enable_receiver.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/models/__init__.py index df5fd096a3c5..2755a8fd3548 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/models/__init__.py @@ -25,7 +25,7 @@ from ._monitor_management_client_enums import ReceiverStatus from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/models/_models_py3.py index 9324ebe7603d..0d67186423bd 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/models/_models_py3.py @@ -7,10 +7,14 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Dict, List, Optional +from typing import Any, Dict, List, Optional, TYPE_CHECKING from ... import _serialization +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models + class ActionGroupList(_serialization.Model): """A list of action groups. @@ -27,8 +31,12 @@ class ActionGroupList(_serialization.Model): } def __init__( - self, *, value: Optional[List["_models.ActionGroupResource"]] = None, next_link: Optional[str] = None, **kwargs - ): + self, + *, + value: Optional[List["_models.ActionGroupResource"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: """ :keyword value: The list of action groups. :paramtype value: list[~$(python-base-namespace).v2019_06_01.models.ActionGroupResource] @@ -55,7 +63,7 @@ class ActionGroupPatchBody(_serialization.Model): "enabled": {"key": "properties.enabled", "type": "bool"}, } - def __init__(self, *, tags: Optional[Dict[str, str]] = None, enabled: bool = True, **kwargs): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, enabled: bool = True, **kwargs: Any) -> None: """ :keyword tags: Resource tags. :paramtype tags: dict[str, str] @@ -102,7 +110,7 @@ class AzureResource(_serialization.Model): "tags": {"key": "tags", "type": "{str}"}, } - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: """ :keyword location: Resource location. Required. :paramtype location: str @@ -217,8 +225,8 @@ def __init__( logic_app_receivers: Optional[List["_models.LogicAppReceiver"]] = None, azure_function_receivers: Optional[List["_models.AzureFunctionReceiver"]] = None, arm_role_receivers: Optional[List["_models.ArmRoleReceiver"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword location: Resource location. Required. :paramtype location: str @@ -302,7 +310,7 @@ class ArmRoleReceiver(_serialization.Model): "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, } - def __init__(self, *, name: str, role_id: str, use_common_alert_schema: bool = False, **kwargs): + def __init__(self, *, name: str, role_id: str, use_common_alert_schema: bool = False, **kwargs: Any) -> None: """ :keyword name: The name of the arm role receiver. Names must be unique across all receivers within an action group. Required. @@ -367,8 +375,8 @@ def __init__( name: Optional[str] = None, service_uri: Optional[str] = None, use_common_alert_schema: bool = False, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword automation_account_id: The Azure automation account Id which holds this runbook and authenticate to Azure resource. Required. @@ -418,7 +426,7 @@ class AzureAppPushReceiver(_serialization.Model): "email_address": {"key": "emailAddress", "type": "str"}, } - def __init__(self, *, name: str, email_address: str, **kwargs): + def __init__(self, *, name: str, email_address: str, **kwargs: Any) -> None: """ :keyword name: The name of the Azure mobile app push receiver. Names must be unique across all receivers within an action group. Required. @@ -472,8 +480,8 @@ def __init__( function_name: str, http_trigger_url: str, use_common_alert_schema: bool = False, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: The name of the azure function receiver. Names must be unique across all receivers within an action group. Required. @@ -527,7 +535,7 @@ class EmailReceiver(_serialization.Model): "status": {"key": "status", "type": "str"}, } - def __init__(self, *, name: str, email_address: str, use_common_alert_schema: bool = False, **kwargs): + def __init__(self, *, name: str, email_address: str, use_common_alert_schema: bool = False, **kwargs: Any) -> None: """ :keyword name: The name of the email receiver. Names must be unique across all receivers within an action group. Required. @@ -561,7 +569,7 @@ class EnableRequest(_serialization.Model): "receiver_name": {"key": "receiverName", "type": "str"}, } - def __init__(self, *, receiver_name: str, **kwargs): + def __init__(self, *, receiver_name: str, **kwargs: Any) -> None: """ :keyword receiver_name: The name of the receiver to resubscribe. Required. :paramtype receiver_name: str @@ -584,7 +592,7 @@ class ErrorResponse(_serialization.Model): "message": {"key": "message", "type": "str"}, } - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: """ :keyword code: Error code. :paramtype code: str @@ -635,8 +643,8 @@ class ItsmReceiver(_serialization.Model): } def __init__( - self, *, name: str, workspace_id: str, connection_id: str, ticket_configuration: str, region: str, **kwargs - ): + self, *, name: str, workspace_id: str, connection_id: str, ticket_configuration: str, region: str, **kwargs: Any + ) -> None: """ :keyword name: The name of the Itsm receiver. Names must be unique across all receivers within an action group. Required. @@ -692,8 +700,8 @@ class LogicAppReceiver(_serialization.Model): } def __init__( - self, *, name: str, resource_id: str, callback_url: str, use_common_alert_schema: bool = False, **kwargs - ): + self, *, name: str, resource_id: str, callback_url: str, use_common_alert_schema: bool = False, **kwargs: Any + ) -> None: """ :keyword name: The name of the logic app receiver. Names must be unique across all receivers within an action group. Required. @@ -745,7 +753,7 @@ class SmsReceiver(_serialization.Model): "status": {"key": "status", "type": "str"}, } - def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs): + def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs: Any) -> None: """ :keyword name: The name of the SMS receiver. Names must be unique across all receivers within an action group. Required. @@ -788,7 +796,7 @@ class VoiceReceiver(_serialization.Model): "phone_number": {"key": "phoneNumber", "type": "str"}, } - def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs): + def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs: Any) -> None: """ :keyword name: The name of the voice receiver. Names must be unique across all receivers within an action group. Required. @@ -851,8 +859,8 @@ def __init__( object_id: Optional[str] = None, identifier_uri: Optional[str] = None, tenant_id: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: The name of the webhook receiver. Names must be unique across all receivers within an action group. Required. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/operations/__init__.py index 0e396f5d7fb0..05f0527dc979 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/operations/__init__.py @@ -9,7 +9,7 @@ from ._action_groups_operations import ActionGroupsOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/operations/_action_groups_operations.py index c00526c4a38d..2b2644412e49 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/operations/_action_groups_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/operations/_action_groups_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -42,8 +47,8 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2019-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -59,7 +64,7 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -78,7 +83,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + api_version: Literal["2019-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -94,7 +99,7 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -111,7 +116,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + api_version: Literal["2019-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -127,7 +132,7 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -144,8 +149,8 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2019-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -161,7 +166,7 @@ def build_update_request( "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -178,7 +183,7 @@ def build_list_by_subscription_id_request(subscription_id: str, **kwargs: Any) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + api_version: Literal["2019-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -187,7 +192,7 @@ def build_list_by_subscription_id_request(subscription_id: str, **kwargs: Any) - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -202,7 +207,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str + api_version: Literal["2019-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -217,7 +222,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -234,8 +239,8 @@ def build_enable_receiver_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2019-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -251,7 +256,7 @@ def build_enable_receiver_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -354,8 +359,8 @@ def create_or_update( :type resource_group_name: str :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group: The action group to create or use for the update. Is either a model type - or a IO type. Required. + :param action_group: The action group to create or use for the update. Is either a + ActionGroupResource type or a IO type. Required. :type action_group: ~$(python-base-namespace).v2019_06_01.models.ActionGroupResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -376,9 +381,9 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] + api_version: Literal["2019-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -401,9 +406,9 @@ def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -421,11 +426,13 @@ def create_or_update( deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" + } @distributed_trace def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) -> _models.ActionGroupResource: @@ -452,8 +459,8 @@ def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) - _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] + api_version: Literal["2019-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) + cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -465,9 +472,9 @@ def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) - params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -485,7 +492,9 @@ def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) - return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -514,8 +523,8 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2019-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -527,9 +536,9 @@ def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -543,7 +552,9 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" + } @overload def update( @@ -616,8 +627,8 @@ def update( :type resource_group_name: str :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Is either a model type or a IO - type. Required. + :param action_group_patch: Parameters supplied to the operation. Is either a + ActionGroupPatchBody type or a IO type. Required. :type action_group_patch: ~$(python-base-namespace).v2019_06_01.models.ActionGroupPatchBody or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -639,9 +650,9 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] + api_version: Literal["2019-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -664,9 +675,9 @@ def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -684,7 +695,9 @@ def update( return deserialized - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}" + } @distributed_trace def list_by_subscription_id(self, **kwargs: Any) -> Iterable["_models.ActionGroupResource"]: @@ -699,8 +712,8 @@ def list_by_subscription_id(self, **kwargs: Any) -> Iterable["_models.ActionGrou _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + api_version: Literal["2019-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) + cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -721,16 +734,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -738,13 +758,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ActionGroupList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -758,7 +778,9 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_subscription_id.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups"} # type: ignore + list_by_subscription_id.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups" + } @distributed_trace def list_by_resource_group( @@ -778,8 +800,8 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + api_version: Literal["2019-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) + cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -801,16 +823,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -818,13 +847,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ActionGroupList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -838,7 +867,9 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups" + } @overload def enable_receiver( # pylint: disable=inconsistent-return-statements @@ -914,7 +945,7 @@ def enable_receiver( # pylint: disable=inconsistent-return-statements :type resource_group_name: str :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param enable_request: The receiver to re-enable. Is either a model type or a IO type. + :param enable_request: The receiver to re-enable. Is either a EnableRequest type or a IO type. Required. :type enable_request: ~$(python-base-namespace).v2019_06_01.models.EnableRequest or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -936,9 +967,9 @@ def enable_receiver( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2019-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -961,9 +992,9 @@ def enable_receiver( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -977,4 +1008,6 @@ def enable_receiver( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - enable_receiver.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe"} # type: ignore + enable_receiver.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/__init__.py index 8ba4823444a9..2c7733bfd566 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/__init__.py @@ -13,12 +13,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["MonitorManagementClient"] +__all__ = [ + "MonitorManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_configuration.py index 1b892f93ef1e..629cf210dc21 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -36,7 +42,7 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2019-10-17-preview") # type: str + api_version: Literal["2019-10-17-preview"] = kwargs.pop("api_version", "2019-10-17-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -50,10 +56,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, **kwargs # type: Any - ): - # type: (...) -> None + def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_metadata.json index 77cfc19d416c..cd2778252553 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_metadata.json @@ -19,13 +19,15 @@ "signature": "credential: \"TokenCredential\",", "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true + "required": true, + "method_location": "positional" }, "subscription_id": { "signature": "subscription_id: str,", "description": "The ID of the target subscription. Required.", "docstring_type": "str", - "required": true + "required": true, + "method_location": "positional" } }, "async": { @@ -48,22 +50,25 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "signature": "api_version: Optional[str]=None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } }, "async": { @@ -71,19 +76,22 @@ "signature": "api_version: Optional[str] = None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { "signature": "profile: KnownProfiles = KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } } } @@ -103,4 +111,4 @@ "private_endpoint_connections": "PrivateEndpointConnectionsOperations", "private_link_scoped_resources": "PrivateLinkScopedResourcesOperations" } -} \ No newline at end of file +} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_monitor_management_client.py index efb720dba23a..60aba7429624 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_monitor_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from . import models +from . import models as _models from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ( @@ -71,7 +71,7 @@ def __init__( ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -113,15 +113,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> MonitorManagementClient + def __enter__(self) -> "MonitorManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_vendor.py index 9aad73fc743e..bd0df84f5319 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_vendor.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_vendor.py @@ -5,6 +5,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import List, cast + from azure.core.pipeline.transport import HttpRequest @@ -22,6 +24,7 @@ def _format_url_section(template, **kwargs): try: return template.format(**kwargs) except KeyError as key: - formatted_components = template.split("/") + # Need the cast, as for some reasons "split" is typed as list[str | Any] + formatted_components = cast(List[str], template.split("/")) components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_version.py index ce9ac7ae37b3..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/__init__.py index 8638dc69d869..2c151bb41c19 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/__init__.py @@ -10,12 +10,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["MonitorManagementClient"] +__all__ = [ + "MonitorManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/_configuration.py index 8c24d0c65cac..91e52467400f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -36,7 +42,7 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2019-10-17-preview") # type: str + api_version: Literal["2019-10-17-preview"] = kwargs.pop("api_version", "2019-10-17-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/_monitor_management_client.py index b1b03a095e9e..9757cf2618d0 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/_monitor_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from .. import models +from .. import models as _models from ..._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ( @@ -71,7 +71,7 @@ def __init__( ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -120,5 +120,5 @@ async def __aenter__(self) -> "MonitorManagementClient": await self._client.__aenter__() return self - async def __aexit__(self, *exc_details) -> None: + async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/__init__.py index 6737f122eff7..1f7c00746a8d 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/__init__.py @@ -13,7 +13,7 @@ from ._private_link_scoped_resources_operations import PrivateLinkScopedResourcesOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_endpoint_connections_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_endpoint_connections_operations.py index 9922970324a9..208e4fe44e93 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_endpoint_connections_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -37,6 +38,10 @@ build_list_by_private_link_scope_request, ) +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -89,8 +94,10 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -103,9 +110,9 @@ async def get( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -122,7 +129,9 @@ async def get( return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}" + } async def _create_or_update_initial( self, @@ -143,9 +152,11 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PrivateEndpointConnection]] + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -169,9 +180,9 @@ async def _create_or_update_initial( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -190,7 +201,9 @@ async def _create_or_update_initial( return deserialized - _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}" + } @overload async def begin_create_or_update( @@ -290,7 +303,7 @@ async def begin_create_or_update( :type scope_name: str :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str - :param parameters: Is either a model type or a IO type. Required. + :param parameters: Is either a PrivateEndpointConnection type or a IO type. Required. :type parameters: ~$(python-base-namespace).v2019_10_17.models.PrivateEndpointConnection or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -312,14 +325,16 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._create_or_update_initial( # type: ignore + raw_result = await self._create_or_update_initial( resource_group_name=resource_group_name, scope_name=scope_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -340,7 +355,7 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: @@ -352,9 +367,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, scope_name: str, private_endpoint_connection_name: str, **kwargs: Any @@ -370,8 +387,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -384,9 +403,9 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -399,7 +418,9 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}" + } @distributed_trace_async async def begin_delete( @@ -429,11 +450,13 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, @@ -452,7 +475,7 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: @@ -464,9 +487,11 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}" + } @distributed_trace def list_by_private_link_scope( @@ -489,8 +514,10 @@ def list_by_private_link_scope( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) + cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -513,16 +540,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -530,13 +564,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -549,4 +583,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_private_link_scope.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections"} # type: ignore + list_by_private_link_scope.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_resources_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_resources_operations.py index 0ca1be88aa20..2150622a07ef 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_resources_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_resources_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -30,6 +31,10 @@ from ..._vendor import _convert_request from ...operations._private_link_resources_operations import build_get_request, build_list_by_private_link_scope_request +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -73,8 +78,10 @@ def list_by_private_link_scope( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResourceListResult] + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) + cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -97,16 +104,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -114,13 +128,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -133,7 +147,9 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_private_link_scope.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateLinkResources"} # type: ignore + list_by_private_link_scope.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateLinkResources" + } @distributed_trace_async async def get( @@ -164,8 +180,10 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResource] + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) + cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -178,9 +196,9 @@ async def get( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -197,4 +215,6 @@ async def get( return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateLinkResources/{groupName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateLinkResources/{groupName}" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_scope_operation_status_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_scope_operation_status_operations.py index a58d06892bc4..6672d3a8f615 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_scope_operation_status_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_scope_operation_status_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -27,6 +28,10 @@ from ..._vendor import _convert_request from ...operations._private_link_scope_operation_status_operations import build_get_request +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -76,8 +81,10 @@ async def get(self, async_operation_id: str, resource_group_name: str, **kwargs: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationStatus] + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) + cls: ClsType[_models.OperationStatus] = kwargs.pop("cls", None) request = build_get_request( async_operation_id=async_operation_id, @@ -89,9 +96,9 @@ async def get(self, async_operation_id: str, resource_group_name: str, **kwargs: params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -108,4 +115,6 @@ async def get(self, async_operation_id: str, resource_group_name: str, **kwargs: return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopeOperationStatuses/{asyncOperationId}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopeOperationStatuses/{asyncOperationId}" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_scoped_resources_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_scoped_resources_operations.py index 26965d0e6eb9..9ce1d2ab91ec 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_scoped_resources_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_scoped_resources_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -37,6 +38,10 @@ build_list_by_private_link_scope_request, ) +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -87,8 +92,10 @@ async def get(self, resource_group_name: str, scope_name: str, name: str, **kwar _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ScopedResource] + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) + cls: ClsType[_models.ScopedResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -101,9 +108,9 @@ async def get(self, resource_group_name: str, scope_name: str, name: str, **kwar params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -120,7 +127,9 @@ async def get(self, resource_group_name: str, scope_name: str, name: str, **kwar return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}" + } async def _create_or_update_initial( self, @@ -141,9 +150,11 @@ async def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ScopedResource]] + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.ScopedResource]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -167,9 +178,9 @@ async def _create_or_update_initial( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -191,7 +202,9 @@ async def _create_or_update_initial( return deserialized - _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}"} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}" + } @overload async def begin_create_or_update( @@ -291,7 +304,7 @@ async def begin_create_or_update( :type scope_name: str :param name: The name of the scoped resource object. Required. :type name: str - :param parameters: Is either a model type or a IO type. Required. + :param parameters: Is either a ScopedResource type or a IO type. Required. :type parameters: ~$(python-base-namespace).v2019_10_17.models.ScopedResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -313,14 +326,16 @@ async def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ScopedResource] - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopedResource] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._create_or_update_initial( # type: ignore + raw_result = await self._create_or_update_initial( resource_group_name=resource_group_name, scope_name=scope_name, name=name, @@ -341,7 +356,7 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: @@ -353,9 +368,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, scope_name: str, name: str, **kwargs: Any @@ -371,8 +388,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -385,9 +404,9 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -400,7 +419,9 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}"} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}" + } @distributed_trace_async async def begin_delete( @@ -430,11 +451,13 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, @@ -453,7 +476,7 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: @@ -465,9 +488,11 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}" + } @distributed_trace def list_by_private_link_scope( @@ -489,8 +514,10 @@ def list_by_private_link_scope( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ScopedResourceListResult] + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) + cls: ClsType[_models.ScopedResourceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -513,16 +540,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -530,13 +564,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ScopedResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -549,4 +583,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_private_link_scope.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources"} # type: ignore + list_by_private_link_scope.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_scopes_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_scopes_operations.py index 82caf75a2af8..6c4654932afd 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_scopes_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_scopes_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -39,6 +40,10 @@ build_update_tags_request, ) +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -76,8 +81,10 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.AzureMonitorPrivateLinkS _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.AzureMonitorPrivateLinkScopeListResult] + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) + cls: ClsType[_models.AzureMonitorPrivateLinkScopeListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -98,16 +105,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -115,13 +129,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("AzureMonitorPrivateLinkScopeListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -134,7 +148,7 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/privateLinkScopes"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/privateLinkScopes"} @distributed_trace def list_by_resource_group( @@ -155,8 +169,10 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.AzureMonitorPrivateLinkScopeListResult] + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) + cls: ClsType[_models.AzureMonitorPrivateLinkScopeListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -178,16 +194,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -195,13 +218,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("AzureMonitorPrivateLinkScopeListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -214,7 +237,9 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes" + } async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, scope_name: str, **kwargs: Any @@ -230,8 +255,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -243,9 +270,9 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -258,7 +285,9 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}"} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}" + } @distributed_trace_async async def begin_delete(self, resource_group_name: str, scope_name: str, **kwargs: Any) -> AsyncLROPoller[None]: @@ -284,11 +313,13 @@ async def begin_delete(self, resource_group_name: str, scope_name: str, **kwargs _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, @@ -306,7 +337,7 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: @@ -318,9 +349,11 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}" + } @distributed_trace_async async def get( @@ -349,8 +382,10 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.AzureMonitorPrivateLinkScope] + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) + cls: ClsType[_models.AzureMonitorPrivateLinkScope] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -362,9 +397,9 @@ async def get( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -381,7 +416,9 @@ async def get( return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}" + } @overload async def create_or_update( @@ -461,7 +498,8 @@ async def create_or_update( :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. :type scope_name: str :param azure_monitor_private_link_scope_payload: Properties that need to be specified to create - or update a Azure Monitor PrivateLinkScope. Is either a model type or a IO type. Required. + or update a Azure Monitor PrivateLinkScope. Is either a AzureMonitorPrivateLinkScope type or a + IO type. Required. :type azure_monitor_private_link_scope_payload: ~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScope or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -483,9 +521,11 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.AzureMonitorPrivateLinkScope] + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AzureMonitorPrivateLinkScope] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -508,9 +548,9 @@ async def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -527,11 +567,13 @@ async def create_or_update( deserialized = self._deserialize("AzureMonitorPrivateLinkScope", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}" + } @overload async def update_tags( @@ -610,7 +652,7 @@ async def update_tags( :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. :type scope_name: str :param private_link_scope_tags: Updated tag information to set into the PrivateLinkScope - instance. Is either a model type or a IO type. Required. + instance. Is either a TagsResource type or a IO type. Required. :type private_link_scope_tags: ~$(python-base-namespace).v2019_10_17.models.TagsResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -631,9 +673,11 @@ async def update_tags( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.AzureMonitorPrivateLinkScope] + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AzureMonitorPrivateLinkScope] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -656,9 +700,9 @@ async def update_tags( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -675,4 +719,6 @@ async def update_tags( return deserialized - update_tags.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}"} # type: ignore + update_tags.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/models/__init__.py index 53f978c6d85f..5947e1f13a83 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/models/__init__.py @@ -24,7 +24,7 @@ from ._models_py3 import ScopedResourceListResult from ._models_py3 import TagsResource from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/models/_models_py3.py index 991e73282eb6..f77683ee4009 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/models/_models_py3.py @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, TYPE_CHECKING +from typing import Any, Dict, List, Optional, TYPE_CHECKING from ... import _serialization @@ -51,7 +51,7 @@ class PrivateLinkScopesResource(_serialization.Model): "tags": {"key": "tags", "type": "{str}"}, } - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: """ :keyword location: Resource location. Required. :paramtype location: str @@ -114,7 +114,7 @@ class AzureMonitorPrivateLinkScope(PrivateLinkScopesResource): }, } - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: """ :keyword location: Resource location. Required. :paramtype location: str @@ -148,8 +148,8 @@ class AzureMonitorPrivateLinkScopeListResult(_serialization.Model): } def __init__( - self, *, value: List["_models.AzureMonitorPrivateLinkScope"], next_link: Optional[str] = None, **kwargs - ): + self, *, value: List["_models.AzureMonitorPrivateLinkScope"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword value: List of Azure Monitor PrivateLinkScope definitions. Required. :paramtype value: @@ -184,7 +184,7 @@ class ErrorAdditionalInfo(_serialization.Model): "info": {"key": "info", "type": "object"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.type = None @@ -205,7 +205,7 @@ class ErrorResponse(_serialization.Model): "message": {"key": "message", "type": "str"}, } - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: """ :keyword code: Error code. :paramtype code: str @@ -245,7 +245,7 @@ class ErrorResponseCommon(ErrorResponse): "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: """ :keyword code: Error code. :paramtype code: str @@ -292,8 +292,8 @@ def __init__( end_time: Optional[datetime.datetime] = None, status: Optional[str] = None, error: Optional["_models.ErrorResponseCommon"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword id: The operation Id. :paramtype id: str @@ -342,7 +342,7 @@ class ProxyResource(_serialization.Model): "type": {"key": "type", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.id = None @@ -395,8 +395,8 @@ def __init__( *, private_endpoint: Optional["_models.PrivateEndpointProperty"] = None, private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionStateProperty"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword private_endpoint: Private endpoint which the connection belongs to. :paramtype private_endpoint: @@ -433,7 +433,7 @@ class PrivateEndpointConnectionListResult(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.value = None @@ -451,7 +451,7 @@ class PrivateEndpointProperty(_serialization.Model): "id": {"key": "id", "type": "str"}, } - def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin + def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylint: disable=redefined-builtin """ :keyword id: Resource id of the private endpoint. :paramtype id: str @@ -493,7 +493,7 @@ class PrivateLinkResource(ProxyResource): "required_members": {"key": "properties.requiredMembers", "type": "[str]"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.group_id = None @@ -521,7 +521,7 @@ class PrivateLinkResourceListResult(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.value = None @@ -555,7 +555,7 @@ class PrivateLinkServiceConnectionStateProperty(_serialization.Model): "actions_required": {"key": "actionsRequired", "type": "str"}, } - def __init__(self, *, status: str, description: str, **kwargs): + def __init__(self, *, status: str, description: str, **kwargs: Any) -> None: """ :keyword status: The private link service connection status. Required. :paramtype status: str @@ -600,7 +600,7 @@ class ScopedResource(ProxyResource): "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } - def __init__(self, *, linked_resource_id: Optional[str] = None, **kwargs): + def __init__(self, *, linked_resource_id: Optional[str] = None, **kwargs: Any) -> None: """ :keyword linked_resource_id: The resource id of the scoped Azure monitor resource. :paramtype linked_resource_id: str @@ -631,7 +631,7 @@ class ScopedResourceListResult(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.value = None @@ -639,7 +639,8 @@ def __init__(self, **kwargs): class TagsResource(_serialization.Model): - """A container holding only the Tags for a resource, allowing the user to update the tags on a PrivateLinkScope instance. + """A container holding only the Tags for a resource, allowing the user to update the tags on a + PrivateLinkScope instance. :ivar tags: Resource tags. :vartype tags: dict[str, str] @@ -649,7 +650,7 @@ class TagsResource(_serialization.Model): "tags": {"key": "tags", "type": "{str}"}, } - def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: """ :keyword tags: Resource tags. :paramtype tags: dict[str, str] diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/__init__.py index 6737f122eff7..1f7c00746a8d 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/__init__.py @@ -13,7 +13,7 @@ from ._private_link_scoped_resources_operations import PrivateLinkScopedResourcesOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_endpoint_connections_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_endpoint_connections_operations.py index db90d0252934..6b797c1e193f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_endpoint_connections_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_endpoint_connections_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -31,6 +32,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -48,7 +53,9 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -67,7 +74,7 @@ def build_get_request( ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -88,8 +95,10 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -108,7 +117,7 @@ def build_create_or_update_request( ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -130,7 +139,9 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) # Construct URL _url = kwargs.pop( "template_url", @@ -147,7 +158,7 @@ def build_delete_request( ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -161,7 +172,9 @@ def build_list_by_private_link_scope_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -177,7 +190,7 @@ def build_list_by_private_link_scope_request( "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -236,8 +249,10 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -250,9 +265,9 @@ def get( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -269,7 +284,9 @@ def get( return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}" + } def _create_or_update_initial( self, @@ -290,9 +307,11 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PrivateEndpointConnection]] + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.PrivateEndpointConnection]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -316,9 +335,9 @@ def _create_or_update_initial( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -337,7 +356,9 @@ def _create_or_update_initial( return deserialized - _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}" + } @overload def begin_create_or_update( @@ -437,7 +458,7 @@ def begin_create_or_update( :type scope_name: str :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str - :param parameters: Is either a model type or a IO type. Required. + :param parameters: Is either a PrivateEndpointConnection type or a IO type. Required. :type parameters: ~$(python-base-namespace).v2019_10_17.models.PrivateEndpointConnection or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -459,14 +480,16 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._create_or_update_initial( # type: ignore + raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, scope_name=scope_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -487,7 +510,7 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: @@ -499,9 +522,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, scope_name: str, private_endpoint_connection_name: str, **kwargs: Any @@ -517,8 +542,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -531,9 +558,9 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -546,7 +573,9 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}" + } @distributed_trace def begin_delete( @@ -576,11 +605,13 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, @@ -599,7 +630,7 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) if polling is True: - polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: @@ -611,9 +642,11 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}" + } @distributed_trace def list_by_private_link_scope( @@ -636,8 +669,10 @@ def list_by_private_link_scope( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) + cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -660,16 +695,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -677,13 +719,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -696,4 +738,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_private_link_scope.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections"} # type: ignore + list_by_private_link_scope.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_resources_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_resources_operations.py index f3bcfba11986..24d6ce10286d 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_resources_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_resources_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -42,7 +47,9 @@ def build_list_by_private_link_scope_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -58,7 +65,7 @@ def build_list_by_private_link_scope_request( "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -75,7 +82,9 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -92,7 +101,7 @@ def build_get_request( "groupName": _SERIALIZER.url("group_name", group_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -142,8 +151,10 @@ def list_by_private_link_scope( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResourceListResult] + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) + cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -166,16 +177,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -183,13 +201,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -202,7 +220,9 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_private_link_scope.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateLinkResources"} # type: ignore + list_by_private_link_scope.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateLinkResources" + } @distributed_trace def get( @@ -233,8 +253,10 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResource] + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) + cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -247,9 +269,9 @@ def get( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -266,4 +288,6 @@ def get( return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateLinkResources/{groupName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateLinkResources/{groupName}" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_scope_operation_status_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_scope_operation_status_operations.py index ce0df0ab7f9e..d3e23b3992b8 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_scope_operation_status_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_scope_operation_status_operations.py @@ -6,6 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -27,6 +28,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,9 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -56,7 +63,7 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -112,8 +119,10 @@ def get(self, async_operation_id: str, resource_group_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationStatus] + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) + cls: ClsType[_models.OperationStatus] = kwargs.pop("cls", None) request = build_get_request( async_operation_id=async_operation_id, @@ -125,9 +134,9 @@ def get(self, async_operation_id: str, resource_group_name: str, **kwargs: Any) params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -144,4 +153,6 @@ def get(self, async_operation_id: str, resource_group_name: str, **kwargs: Any) return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopeOperationStatuses/{asyncOperationId}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopeOperationStatuses/{asyncOperationId}" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_scoped_resources_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_scoped_resources_operations.py index d51b7e06ab25..a36e534e05ff 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_scoped_resources_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_scoped_resources_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -31,6 +32,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -44,7 +49,9 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -61,7 +68,7 @@ def build_get_request( "name": _SERIALIZER.url("name", name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -78,8 +85,10 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -96,7 +105,7 @@ def build_create_or_update_request( "name": _SERIALIZER.url("name", name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -114,7 +123,9 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) # Construct URL _url = kwargs.pop( "template_url", @@ -129,7 +140,7 @@ def build_delete_request( "name": _SERIALIZER.url("name", name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -143,7 +154,9 @@ def build_list_by_private_link_scope_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -159,7 +172,7 @@ def build_list_by_private_link_scope_request( "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -216,8 +229,10 @@ def get(self, resource_group_name: str, scope_name: str, name: str, **kwargs: An _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ScopedResource] + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) + cls: ClsType[_models.ScopedResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -230,9 +245,9 @@ def get(self, resource_group_name: str, scope_name: str, name: str, **kwargs: An params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -249,7 +264,9 @@ def get(self, resource_group_name: str, scope_name: str, name: str, **kwargs: An return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}" + } def _create_or_update_initial( self, @@ -270,9 +287,11 @@ def _create_or_update_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ScopedResource]] + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.ScopedResource]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -296,9 +315,9 @@ def _create_or_update_initial( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -320,7 +339,9 @@ def _create_or_update_initial( return deserialized - _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}"} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}" + } @overload def begin_create_or_update( @@ -420,7 +441,7 @@ def begin_create_or_update( :type scope_name: str :param name: The name of the scoped resource object. Required. :type name: str - :param parameters: Is either a model type or a IO type. Required. + :param parameters: Is either a ScopedResource type or a IO type. Required. :type parameters: ~$(python-base-namespace).v2019_10_17.models.ScopedResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -442,14 +463,16 @@ def begin_create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ScopedResource] - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScopedResource] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._create_or_update_initial( # type: ignore + raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, scope_name=scope_name, name=name, @@ -470,7 +493,7 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: @@ -482,9 +505,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}"} # type: ignore + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}" + } def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, scope_name: str, name: str, **kwargs: Any @@ -500,8 +525,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -514,9 +541,9 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -529,7 +556,9 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}"} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}" + } @distributed_trace def begin_delete(self, resource_group_name: str, scope_name: str, name: str, **kwargs: Any) -> LROPoller[None]: @@ -557,11 +586,13 @@ def begin_delete(self, resource_group_name: str, scope_name: str, name: str, **k _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, @@ -580,7 +611,7 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) if polling is True: - polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: @@ -592,9 +623,11 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}" + } @distributed_trace def list_by_private_link_scope( @@ -616,8 +649,10 @@ def list_by_private_link_scope( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ScopedResourceListResult] + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) + cls: ClsType[_models.ScopedResourceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -640,16 +675,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -657,13 +699,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ScopedResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -676,4 +718,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_private_link_scope.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources"} # type: ignore + list_by_private_link_scope.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_scopes_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_scopes_operations.py index aed0b73ecb7a..73a396ecd911 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_scopes_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_scopes_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -31,6 +32,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -42,7 +47,9 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -51,7 +58,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -66,7 +73,9 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -81,7 +90,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -95,7 +104,9 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ def build_delete_request(resource_group_name: str, scope_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) # Construct URL _url = kwargs.pop( "template_url", @@ -109,7 +120,7 @@ def build_delete_request(resource_group_name: str, scope_name: str, subscription "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -121,7 +132,9 @@ def build_get_request(resource_group_name: str, scope_name: str, subscription_id _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -137,7 +150,7 @@ def build_get_request(resource_group_name: str, scope_name: str, subscription_id "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -154,8 +167,10 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -171,7 +186,7 @@ def build_create_or_update_request( "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -190,8 +205,10 @@ def build_update_tags_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -207,7 +224,7 @@ def build_update_tags_request( "scopeName": _SERIALIZER.url("scope_name", scope_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -253,8 +270,10 @@ def list(self, **kwargs: Any) -> Iterable["_models.AzureMonitorPrivateLinkScope" _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.AzureMonitorPrivateLinkScopeListResult] + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) + cls: ClsType[_models.AzureMonitorPrivateLinkScopeListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -275,16 +294,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -292,13 +318,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("AzureMonitorPrivateLinkScopeListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -311,7 +337,7 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/privateLinkScopes"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/microsoft.insights/privateLinkScopes"} @distributed_trace def list_by_resource_group( @@ -332,8 +358,10 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.AzureMonitorPrivateLinkScopeListResult] + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) + cls: ClsType[_models.AzureMonitorPrivateLinkScopeListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -355,16 +383,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -372,13 +407,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("AzureMonitorPrivateLinkScopeListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -391,7 +426,9 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes" + } def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, scope_name: str, **kwargs: Any @@ -407,8 +444,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -420,9 +459,9 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -435,7 +474,9 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}"} # type: ignore + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}" + } @distributed_trace def begin_delete(self, resource_group_name: str, scope_name: str, **kwargs: Any) -> LROPoller[None]: @@ -461,11 +502,13 @@ def begin_delete(self, resource_group_name: str, scope_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, @@ -483,7 +526,7 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return cls(pipeline_response, None, {}) if polling is True: - polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: @@ -495,9 +538,11 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}"} # type: ignore + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}" + } @distributed_trace def get(self, resource_group_name: str, scope_name: str, **kwargs: Any) -> _models.AzureMonitorPrivateLinkScope: @@ -524,8 +569,10 @@ def get(self, resource_group_name: str, scope_name: str, **kwargs: Any) -> _mode _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.AzureMonitorPrivateLinkScope] + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) + cls: ClsType[_models.AzureMonitorPrivateLinkScope] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -537,9 +584,9 @@ def get(self, resource_group_name: str, scope_name: str, **kwargs: Any) -> _mode params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -556,7 +603,9 @@ def get(self, resource_group_name: str, scope_name: str, **kwargs: Any) -> _mode return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}" + } @overload def create_or_update( @@ -636,7 +685,8 @@ def create_or_update( :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. :type scope_name: str :param azure_monitor_private_link_scope_payload: Properties that need to be specified to create - or update a Azure Monitor PrivateLinkScope. Is either a model type or a IO type. Required. + or update a Azure Monitor PrivateLinkScope. Is either a AzureMonitorPrivateLinkScope type or a + IO type. Required. :type azure_monitor_private_link_scope_payload: ~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScope or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -658,9 +708,11 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.AzureMonitorPrivateLinkScope] + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AzureMonitorPrivateLinkScope] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -683,9 +735,9 @@ def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -702,11 +754,13 @@ def create_or_update( deserialized = self._deserialize("AzureMonitorPrivateLinkScope", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}" + } @overload def update_tags( @@ -785,7 +839,7 @@ def update_tags( :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. Required. :type scope_name: str :param private_link_scope_tags: Updated tag information to set into the PrivateLinkScope - instance. Is either a model type or a IO type. Required. + instance. Is either a TagsResource type or a IO type. Required. :type private_link_scope_tags: ~$(python-base-namespace).v2019_10_17.models.TagsResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -806,9 +860,11 @@ def update_tags( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-10-17-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.AzureMonitorPrivateLinkScope] + api_version: Literal["2019-10-17-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-10-17-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AzureMonitorPrivateLinkScope] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -831,9 +887,9 @@ def update_tags( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -850,4 +906,6 @@ def update_tags( return deserialized - update_tags.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}"} # type: ignore + update_tags.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/__init__.py index 8ba4823444a9..2c7733bfd566 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/__init__.py @@ -13,12 +13,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["MonitorManagementClient"] +__all__ = [ + "MonitorManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_configuration.py index 501ddf562dc4..45edbfa23014 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -36,7 +42,7 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2019-11-01-preview") # type: str + api_version: Literal["2019-11-01-preview"] = kwargs.pop("api_version", "2019-11-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -50,10 +56,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, **kwargs # type: Any - ): - # type: (...) -> None + def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_metadata.json index 6918f403b326..aa8b405524f5 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_metadata.json @@ -19,13 +19,15 @@ "signature": "credential: \"TokenCredential\",", "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true + "required": true, + "method_location": "positional" }, "subscription_id": { "signature": "subscription_id: str,", "description": "The ID of the target subscription. Required.", "docstring_type": "str", - "required": true + "required": true, + "method_location": "positional" } }, "async": { @@ -48,22 +50,25 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "signature": "api_version: Optional[str]=None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } }, "async": { @@ -71,19 +76,22 @@ "signature": "api_version: Optional[str] = None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { "signature": "profile: KnownProfiles = KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } } } @@ -100,4 +108,4 @@ "data_collection_rule_associations": "DataCollectionRuleAssociationsOperations", "data_collection_rules": "DataCollectionRulesOperations" } -} \ No newline at end of file +} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_monitor_management_client.py index 14008c78ec23..a78890493aad 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_monitor_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from . import models +from . import models as _models from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import DataCollectionRuleAssociationsOperations, DataCollectionRulesOperations @@ -54,7 +54,7 @@ def __init__( ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -87,15 +87,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> MonitorManagementClient + def __enter__(self) -> "MonitorManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_vendor.py index 9aad73fc743e..bd0df84f5319 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_vendor.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_vendor.py @@ -5,6 +5,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import List, cast + from azure.core.pipeline.transport import HttpRequest @@ -22,6 +24,7 @@ def _format_url_section(template, **kwargs): try: return template.format(**kwargs) except KeyError as key: - formatted_components = template.split("/") + # Need the cast, as for some reasons "split" is typed as list[str | Any] + formatted_components = cast(List[str], template.split("/")) components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_version.py index ce9ac7ae37b3..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/__init__.py index 8638dc69d869..2c151bb41c19 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/__init__.py @@ -10,12 +10,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["MonitorManagementClient"] +__all__ = [ + "MonitorManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/_configuration.py index b23b37b819ef..62d02e980b54 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -36,7 +42,7 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2019-11-01-preview") # type: str + api_version: Literal["2019-11-01-preview"] = kwargs.pop("api_version", "2019-11-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/_monitor_management_client.py index 13b75397dc48..c19588f32ea5 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/_monitor_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from .. import models +from .. import models as _models from ..._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import DataCollectionRuleAssociationsOperations, DataCollectionRulesOperations @@ -54,7 +54,7 @@ def __init__( ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -94,5 +94,5 @@ async def __aenter__(self) -> "MonitorManagementClient": await self._client.__aenter__() return self - async def __aexit__(self, *exc_details) -> None: + async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/operations/__init__.py index 8bc953b60497..cb4e5ea6755e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/operations/__init__.py @@ -10,7 +10,7 @@ from ._data_collection_rules_operations import DataCollectionRulesOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/operations/_data_collection_rule_associations_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/operations/_data_collection_rule_associations_operations.py index b9e25917bdce..3b28241e5f8d 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/operations/_data_collection_rule_associations_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/operations/_data_collection_rule_associations_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -36,6 +37,10 @@ build_list_by_rule_request, ) +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -79,8 +84,10 @@ def list_by_resource( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] + api_version: Literal["2019-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-11-01-preview") + ) + cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -101,16 +108,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -120,13 +134,13 @@ async def extract_data(pipeline_response): ) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -140,7 +154,7 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations"} # type: ignore + list_by_resource.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations"} @distributed_trace def list_by_rule( @@ -166,8 +180,10 @@ def list_by_rule( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] + api_version: Literal["2019-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-11-01-preview") + ) + cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -190,16 +206,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -209,13 +232,13 @@ async def extract_data(pipeline_response): ) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -229,7 +252,9 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_rule.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations"} # type: ignore + list_by_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations" + } @distributed_trace_async async def get( @@ -260,8 +285,10 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] + api_version: Literal["2019-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-11-01-preview") + ) + cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] = kwargs.pop("cls", None) request = build_get_request( resource_uri=resource_uri, @@ -272,9 +299,9 @@ async def get( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -292,7 +319,9 @@ async def get( return deserialized - get.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore + get.metadata = { + "url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" + } @overload async def create( @@ -371,7 +400,8 @@ async def create( :type resource_uri: str :param association_name: The name of the association. The name is case insensitive. Required. :type association_name: str - :param body: The payload. Is either a model type or a IO type. Default value is None. + :param body: The payload. Is either a DataCollectionRuleAssociationProxyOnlyResource type or a + IO type. Default value is None. :type body: ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource or IO @@ -395,9 +425,11 @@ async def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] + api_version: Literal["2019-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -422,9 +454,9 @@ async def create( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -442,11 +474,13 @@ async def create( deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore + create.metadata = { + "url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -476,8 +510,10 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2019-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-11-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_uri=resource_uri, @@ -488,9 +524,9 @@ async def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -504,4 +540,6 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore + delete.metadata = { + "url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/operations/_data_collection_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/operations/_data_collection_rules_operations.py index 5e8d92ae825f..0743ef96c797 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/operations/_data_collection_rules_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/operations/_data_collection_rules_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -37,6 +38,10 @@ build_update_request, ) +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -81,8 +86,10 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResourceListResult] + api_version: Literal["2019-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-11-01-preview") + ) + cls: ClsType[_models.DataCollectionRuleResourceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -104,16 +111,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -121,13 +135,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("DataCollectionRuleResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -141,7 +155,9 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules" + } @distributed_trace def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.DataCollectionRuleResource"]: @@ -159,8 +175,10 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.DataColl _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResourceListResult] + api_version: Literal["2019-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-11-01-preview") + ) + cls: ClsType[_models.DataCollectionRuleResourceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -181,16 +199,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -198,13 +223,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("DataCollectionRuleResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -218,7 +243,9 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionRules"} # type: ignore + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionRules" + } @distributed_trace_async async def get( @@ -250,8 +277,10 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResource] + api_version: Literal["2019-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-11-01-preview") + ) + cls: ClsType[_models.DataCollectionRuleResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -263,9 +292,9 @@ async def get( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -283,7 +312,9 @@ async def get( return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" + } @overload async def create( @@ -365,7 +396,8 @@ async def create( :param data_collection_rule_name: The name of the data collection rule. The name is case insensitive. Required. :type data_collection_rule_name: str - :param body: The payload. Is either a model type or a IO type. Default value is None. + :param body: The payload. Is either a DataCollectionRuleResource type or a IO type. Default + value is None. :type body: ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -387,9 +419,11 @@ async def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResource] + api_version: Literal["2019-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataCollectionRuleResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -415,9 +449,9 @@ async def create( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -435,11 +469,13 @@ async def create( deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore + create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" + } @overload async def update( @@ -521,7 +557,8 @@ async def update( :param data_collection_rule_name: The name of the data collection rule. The name is case insensitive. Required. :type data_collection_rule_name: str - :param body: The payload. Is either a model type or a IO type. Default value is None. + :param body: The payload. Is either a ResourceForUpdate type or a IO type. Default value is + None. :type body: ~$(python-base-namespace).v2019_11_01_preview.models.ResourceForUpdate or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -542,9 +579,11 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResource] + api_version: Literal["2019-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataCollectionRuleResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -570,9 +609,9 @@ async def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -590,7 +629,9 @@ async def update( return deserialized - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -622,8 +663,10 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2019-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-11-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -635,9 +678,9 @@ async def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -651,4 +694,6 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/__init__.py index 2fd922c667dc..20e7277139ff 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/__init__.py @@ -42,7 +42,7 @@ from ._monitor_management_client_enums import KnownSyslogDataSourceStreams from ._monitor_management_client_enums import KnownWindowsEventLogDataSourceStreams from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/_models_py3.py index 0b62a84a255b..1dc100b97f9a 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/_models_py3.py @@ -12,13 +12,14 @@ from ... import _serialization -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models if sys.version_info >= (3, 9): from collections.abc import MutableMapping else: from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object @@ -35,7 +36,7 @@ class AzureMonitorMetricsDestination(_serialization.Model): "name": {"key": "name", "type": "str"}, } - def __init__(self, *, name: Optional[str] = None, **kwargs): + def __init__(self, *, name: Optional[str] = None, **kwargs: Any) -> None: """ :keyword name: A friendly name for the destination. This name should be unique across all destinations (regardless of type) within the data @@ -92,8 +93,8 @@ def __init__( data_sources: Optional["_models.DataCollectionRuleDataSources"] = None, destinations: Optional["_models.DataCollectionRuleDestinations"] = None, data_flows: Optional[List["_models.DataFlow"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword description: Description of the data collection rule. :paramtype description: str @@ -143,7 +144,9 @@ class DataCollectionRuleAssociation(_serialization.Model): "provisioning_state": {"key": "provisioningState", "type": "str"}, } - def __init__(self, *, description: Optional[str] = None, data_collection_rule_id: Optional[str] = None, **kwargs): + def __init__( + self, *, description: Optional[str] = None, data_collection_rule_id: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword description: Description of the association. :paramtype description: str @@ -199,7 +202,9 @@ class DataCollectionRuleAssociationProxyOnlyResource(_serialization.Model): "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } - def __init__(self, *, description: Optional[str] = None, data_collection_rule_id: Optional[str] = None, **kwargs): + def __init__( + self, *, description: Optional[str] = None, data_collection_rule_id: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword description: Description of the association. :paramtype description: str @@ -243,8 +248,8 @@ def __init__( *, value: List["_models.DataCollectionRuleAssociationProxyOnlyResource"], next_link: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword value: A list of resources. Required. :paramtype value: @@ -283,7 +288,9 @@ class DataCollectionRuleAssociationProxyOnlyResourceProperties(DataCollectionRul "provisioning_state": {"key": "provisioningState", "type": "str"}, } - def __init__(self, *, description: Optional[str] = None, data_collection_rule_id: Optional[str] = None, **kwargs): + def __init__( + self, *, description: Optional[str] = None, data_collection_rule_id: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword description: Description of the association. :paramtype description: str @@ -324,8 +331,8 @@ def __init__( windows_event_logs: Optional[List["_models.WindowsEventLogDataSource"]] = None, syslog: Optional[List["_models.SyslogDataSource"]] = None, extensions: Optional[List["_models.ExtensionDataSource"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword performance_counters: The list of performance counter data source configurations. :paramtype performance_counters: @@ -348,19 +355,20 @@ def __init__( class DataCollectionRuleDataSources(DataSourcesSpec): """The specification of data sources. - This property is optional and can be omitted if the rule is meant to be used via direct calls to the provisioned endpoint. + This property is optional and can be omitted if the rule is meant to be used via direct calls + to the provisioned endpoint. - :ivar performance_counters: The list of performance counter data source configurations. - :vartype performance_counters: - list[~$(python-base-namespace).v2019_11_01_preview.models.PerfCounterDataSource] - :ivar windows_event_logs: The list of Windows Event Log data source configurations. - :vartype windows_event_logs: - list[~$(python-base-namespace).v2019_11_01_preview.models.WindowsEventLogDataSource] - :ivar syslog: The list of Syslog data source configurations. - :vartype syslog: list[~$(python-base-namespace).v2019_11_01_preview.models.SyslogDataSource] - :ivar extensions: The list of Azure VM extension data source configurations. - :vartype extensions: - list[~$(python-base-namespace).v2019_11_01_preview.models.ExtensionDataSource] + :ivar performance_counters: The list of performance counter data source configurations. + :vartype performance_counters: + list[~$(python-base-namespace).v2019_11_01_preview.models.PerfCounterDataSource] + :ivar windows_event_logs: The list of Windows Event Log data source configurations. + :vartype windows_event_logs: + list[~$(python-base-namespace).v2019_11_01_preview.models.WindowsEventLogDataSource] + :ivar syslog: The list of Syslog data source configurations. + :vartype syslog: list[~$(python-base-namespace).v2019_11_01_preview.models.SyslogDataSource] + :ivar extensions: The list of Azure VM extension data source configurations. + :vartype extensions: + list[~$(python-base-namespace).v2019_11_01_preview.models.ExtensionDataSource] """ _attribute_map = { @@ -377,8 +385,8 @@ def __init__( windows_event_logs: Optional[List["_models.WindowsEventLogDataSource"]] = None, syslog: Optional[List["_models.SyslogDataSource"]] = None, extensions: Optional[List["_models.ExtensionDataSource"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword performance_counters: The list of performance counter data source configurations. :paramtype performance_counters: @@ -422,8 +430,8 @@ def __init__( *, log_analytics: Optional[List["_models.LogAnalyticsDestination"]] = None, azure_monitor_metrics: Optional["_models.DestinationsSpecAzureMonitorMetrics"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword log_analytics: List of Log Analytics destinations. :paramtype log_analytics: @@ -458,8 +466,8 @@ def __init__( *, log_analytics: Optional[List["_models.LogAnalyticsDestination"]] = None, azure_monitor_metrics: Optional["_models.DestinationsSpecAzureMonitorMetrics"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword log_analytics: List of Log Analytics destinations. :paramtype log_analytics: @@ -549,8 +557,8 @@ def __init__( data_sources: Optional["_models.DataCollectionRuleDataSources"] = None, destinations: Optional["_models.DataCollectionRuleDestinations"] = None, data_flows: Optional[List["_models.DataFlow"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword location: The geo-location where the resource lives. Required. :paramtype location: str @@ -609,7 +617,9 @@ class DataCollectionRuleResourceListResult(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, *, value: List["_models.DataCollectionRuleResource"], next_link: Optional[str] = None, **kwargs): + def __init__( + self, *, value: List["_models.DataCollectionRuleResource"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword value: A list of resources. Required. :paramtype value: @@ -668,8 +678,8 @@ def __init__( data_sources: Optional["_models.DataCollectionRuleDataSources"] = None, destinations: Optional["_models.DataCollectionRuleDestinations"] = None, data_flows: Optional[List["_models.DataFlow"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword description: Description of the data collection rule. :paramtype description: str @@ -713,8 +723,8 @@ def __init__( *, streams: Optional[List[Union[str, "_models.KnownDataFlowStreams"]]] = None, destinations: Optional[List[str]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword streams: List of streams for this data flow. :paramtype streams: list[str or @@ -740,7 +750,7 @@ class DestinationsSpecAzureMonitorMetrics(AzureMonitorMetricsDestination): "name": {"key": "name", "type": "str"}, } - def __init__(self, *, name: Optional[str] = None, **kwargs): + def __init__(self, *, name: Optional[str] = None, **kwargs: Any) -> None: """ :keyword name: A friendly name for the destination. This name should be unique across all destinations (regardless of type) within the data @@ -771,7 +781,7 @@ class ErrorAdditionalInfo(_serialization.Model): "info": {"key": "info", "type": "object"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.type = None @@ -812,7 +822,7 @@ class ErrorDetail(_serialization.Model): "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.code = None @@ -823,7 +833,8 @@ def __init__(self, **kwargs): 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.). + """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: ~$(python-base-namespace).v2019_11_01_preview.models.ErrorDetail @@ -833,7 +844,7 @@ class ErrorResponse(_serialization.Model): "error": {"key": "error", "type": "ErrorDetail"}, } - def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs): + def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: """ :keyword error: The error object. :paramtype error: ~$(python-base-namespace).v2019_11_01_preview.models.ErrorDetail @@ -843,27 +854,28 @@ def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs): class ExtensionDataSource(_serialization.Model): - """Definition of which data will be collected from a separate VM extension that integrates with the Azure Monitor Agent. + """Definition of which data will be collected from a separate VM extension that integrates with + the Azure Monitor Agent. Collected from either Windows and Linux machines, depending on which extension is defined. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to Azure. - :ivar streams: List of streams that this data source will be sent to. - A stream indicates what schema will be used for this data and usually what table in Log - Analytics the data will be sent to. - :vartype streams: list[str or - ~$(python-base-namespace).v2019_11_01_preview.models.KnownExtensionDataSourceStreams] - :ivar extension_name: The name of the VM extension. Required. - :vartype extension_name: str - :ivar extension_settings: The extension settings. The format is specific for particular - extension. - :vartype extension_settings: JSON - :ivar input_data_sources: The list of data sources this extension needs data from. - :vartype input_data_sources: list[str] - :ivar name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :vartype name: str + :ivar streams: List of streams that this data source will be sent to. + A stream indicates what schema will be used for this data and usually what table in Log + Analytics the data will be sent to. + :vartype streams: list[str or + ~$(python-base-namespace).v2019_11_01_preview.models.KnownExtensionDataSourceStreams] + :ivar extension_name: The name of the VM extension. Required. + :vartype extension_name: str + :ivar extension_settings: The extension settings. The format is specific for particular + extension. + :vartype extension_settings: JSON + :ivar input_data_sources: The list of data sources this extension needs data from. + :vartype input_data_sources: list[str] + :ivar name: A friendly name for the data source. + This name should be unique across all data sources (regardless of type) within the data + collection rule. + :vartype name: str """ _validation = { @@ -886,8 +898,8 @@ def __init__( extension_settings: Optional[JSON] = None, input_data_sources: Optional[List[str]] = None, name: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword streams: List of streams that this data source will be sent to. A stream indicates what schema will be used for this data and usually what table in Log @@ -939,7 +951,9 @@ class LogAnalyticsDestination(_serialization.Model): "name": {"key": "name", "type": "str"}, } - def __init__(self, *, workspace_resource_id: Optional[str] = None, name: Optional[str] = None, **kwargs): + def __init__( + self, *, workspace_resource_id: Optional[str] = None, name: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword workspace_resource_id: The resource ID of the Log Analytics workspace. :paramtype workspace_resource_id: str @@ -955,26 +969,27 @@ def __init__(self, *, workspace_resource_id: Optional[str] = None, name: Optiona class PerfCounterDataSource(_serialization.Model): - """Definition of which performance counters will be collected and how they will be collected by this data collection rule. + """Definition of which performance counters will be collected and how they will be collected by + this data collection rule. Collected from both Windows and Linux machines where the counter is present. - :ivar streams: List of streams that this data source will be sent to. - A stream indicates what schema will be used for this data and usually what table in Log - Analytics the data will be sent to. - :vartype streams: list[str or - ~$(python-base-namespace).v2019_11_01_preview.models.KnownPerfCounterDataSourceStreams] - :ivar sampling_frequency_in_seconds: The number of seconds between consecutive counter - measurements (samples). - :vartype sampling_frequency_in_seconds: int - :ivar counter_specifiers: A list of specifier names of the performance counters you want to - collect. - Use a wildcard (*) to collect a counter for all instances. - To get a list of performance counters on Windows, run the command 'typeperf'. - :vartype counter_specifiers: list[str] - :ivar name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :vartype name: str + :ivar streams: List of streams that this data source will be sent to. + A stream indicates what schema will be used for this data and usually what table in Log + Analytics the data will be sent to. + :vartype streams: list[str or + ~$(python-base-namespace).v2019_11_01_preview.models.KnownPerfCounterDataSourceStreams] + :ivar sampling_frequency_in_seconds: The number of seconds between consecutive counter + measurements (samples). + :vartype sampling_frequency_in_seconds: int + :ivar counter_specifiers: A list of specifier names of the performance counters you want to + collect. + Use a wildcard (*) to collect a counter for all instances. + To get a list of performance counters on Windows, run the command 'typeperf'. + :vartype counter_specifiers: list[str] + :ivar name: A friendly name for the data source. + This name should be unique across all data sources (regardless of type) within the data + collection rule. + :vartype name: str """ _attribute_map = { @@ -991,8 +1006,8 @@ def __init__( sampling_frequency_in_seconds: Optional[int] = None, counter_specifiers: Optional[List[str]] = None, name: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword streams: List of streams that this data source will be sent to. A stream indicates what schema will be used for this data and usually what table in Log @@ -1030,7 +1045,7 @@ class ResourceForUpdate(_serialization.Model): "tags": {"key": "tags", "type": "{str}"}, } - def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: """ :keyword tags: Resource tags. :paramtype tags: dict[str, str] @@ -1043,21 +1058,21 @@ class SyslogDataSource(_serialization.Model): """Definition of which syslog data will be collected and how it will be collected. Only collected from Linux machines. - :ivar streams: List of streams that this data source will be sent to. - A stream indicates what schema will be used for this data and usually what table in Log - Analytics the data will be sent to. - :vartype streams: list[str or - ~$(python-base-namespace).v2019_11_01_preview.models.KnownSyslogDataSourceStreams] - :ivar facility_names: The list of facility names. - :vartype facility_names: list[str or - ~$(python-base-namespace).v2019_11_01_preview.models.KnownSyslogDataSourceFacilityNames] - :ivar log_levels: The log levels to collect. - :vartype log_levels: list[str or - ~$(python-base-namespace).v2019_11_01_preview.models.KnownSyslogDataSourceLogLevels] - :ivar name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :vartype name: str + :ivar streams: List of streams that this data source will be sent to. + A stream indicates what schema will be used for this data and usually what table in Log + Analytics the data will be sent to. + :vartype streams: list[str or + ~$(python-base-namespace).v2019_11_01_preview.models.KnownSyslogDataSourceStreams] + :ivar facility_names: The list of facility names. + :vartype facility_names: list[str or + ~$(python-base-namespace).v2019_11_01_preview.models.KnownSyslogDataSourceFacilityNames] + :ivar log_levels: The log levels to collect. + :vartype log_levels: list[str or + ~$(python-base-namespace).v2019_11_01_preview.models.KnownSyslogDataSourceLogLevels] + :ivar name: A friendly name for the data source. + This name should be unique across all data sources (regardless of type) within the data + collection rule. + :vartype name: str """ _attribute_map = { @@ -1074,8 +1089,8 @@ def __init__( facility_names: Optional[List[Union[str, "_models.KnownSyslogDataSourceFacilityNames"]]] = None, log_levels: Optional[List[Union[str, "_models.KnownSyslogDataSourceLogLevels"]]] = None, name: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword streams: List of streams that this data source will be sent to. A stream indicates what schema will be used for this data and usually what table in Log @@ -1104,17 +1119,17 @@ class WindowsEventLogDataSource(_serialization.Model): """Definition of which Windows Event Log events will be collected and how they will be collected. Only collected from Windows machines. - :ivar streams: List of streams that this data source will be sent to. - A stream indicates what schema will be used for this data and usually what table in Log - Analytics the data will be sent to. - :vartype streams: list[str or - ~$(python-base-namespace).v2019_11_01_preview.models.KnownWindowsEventLogDataSourceStreams] - :ivar x_path_queries: A list of Windows Event Log queries in XPATH format. - :vartype x_path_queries: list[str] - :ivar name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :vartype name: str + :ivar streams: List of streams that this data source will be sent to. + A stream indicates what schema will be used for this data and usually what table in Log + Analytics the data will be sent to. + :vartype streams: list[str or + ~$(python-base-namespace).v2019_11_01_preview.models.KnownWindowsEventLogDataSourceStreams] + :ivar x_path_queries: A list of Windows Event Log queries in XPATH format. + :vartype x_path_queries: list[str] + :ivar name: A friendly name for the data source. + This name should be unique across all data sources (regardless of type) within the data + collection rule. + :vartype name: str """ _attribute_map = { @@ -1129,8 +1144,8 @@ def __init__( streams: Optional[List[Union[str, "_models.KnownWindowsEventLogDataSourceStreams"]]] = None, x_path_queries: Optional[List[str]] = None, name: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword streams: List of streams that this data source will be sent to. A stream indicates what schema will be used for this data and usually what table in Log diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/operations/__init__.py index 8bc953b60497..cb4e5ea6755e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/operations/__init__.py @@ -10,7 +10,7 @@ from ._data_collection_rules_operations import DataCollectionRulesOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/operations/_data_collection_rule_associations_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/operations/_data_collection_rule_associations_operations.py index b5b63a9e3692..8d4c80148ec8 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/operations/_data_collection_rule_associations_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/operations/_data_collection_rule_associations_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,9 @@ def build_list_by_resource_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 = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str + api_version: Literal["2019-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-11-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -49,7 +56,7 @@ def build_list_by_resource_request(resource_uri: str, **kwargs: Any) -> HttpRequ "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True, min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -66,7 +73,9 @@ def build_list_by_rule_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str + api_version: Literal["2019-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-11-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -82,7 +91,7 @@ def build_list_by_rule_request( "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -97,7 +106,9 @@ def build_get_request(resource_uri: str, association_name: str, **kwargs: Any) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str + api_version: Literal["2019-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-11-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -109,7 +120,7 @@ def build_get_request(resource_uri: str, association_name: str, **kwargs: Any) - "associationName": _SERIALIZER.url("association_name", association_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -124,8 +135,10 @@ def build_create_request(resource_uri: str, association_name: str, **kwargs: Any _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2019-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -137,7 +150,7 @@ def build_create_request(resource_uri: str, association_name: str, **kwargs: Any "associationName": _SERIALIZER.url("association_name", association_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -154,7 +167,9 @@ def build_delete_request(resource_uri: str, association_name: str, **kwargs: Any _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str + api_version: Literal["2019-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-11-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -166,7 +181,7 @@ def build_delete_request(resource_uri: str, association_name: str, **kwargs: Any "associationName": _SERIALIZER.url("association_name", association_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -216,8 +231,10 @@ def list_by_resource( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] + api_version: Literal["2019-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-11-01-preview") + ) + cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -238,16 +255,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -257,13 +281,13 @@ def extract_data(pipeline_response): ) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -277,7 +301,7 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations"} # type: ignore + list_by_resource.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations"} @distributed_trace def list_by_rule( @@ -303,8 +327,10 @@ def list_by_rule( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] + api_version: Literal["2019-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-11-01-preview") + ) + cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -327,16 +353,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -346,13 +379,13 @@ def extract_data(pipeline_response): ) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -366,7 +399,9 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_rule.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations"} # type: ignore + list_by_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations" + } @distributed_trace def get( @@ -397,8 +432,10 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] + api_version: Literal["2019-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-11-01-preview") + ) + cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] = kwargs.pop("cls", None) request = build_get_request( resource_uri=resource_uri, @@ -409,9 +446,9 @@ def get( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -429,7 +466,9 @@ def get( return deserialized - get.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore + get.metadata = { + "url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" + } @overload def create( @@ -508,7 +547,8 @@ def create( :type resource_uri: str :param association_name: The name of the association. The name is case insensitive. Required. :type association_name: str - :param body: The payload. Is either a model type or a IO type. Default value is None. + :param body: The payload. Is either a DataCollectionRuleAssociationProxyOnlyResource type or a + IO type. Default value is None. :type body: ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource or IO @@ -532,9 +572,11 @@ def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] + api_version: Literal["2019-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -559,9 +601,9 @@ def create( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -579,11 +621,13 @@ def create( deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore + create.metadata = { + "url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -613,8 +657,10 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2019-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-11-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_uri=resource_uri, @@ -625,9 +671,9 @@ def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -641,4 +687,6 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore + delete.metadata = { + "url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/operations/_data_collection_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/operations/_data_collection_rules_operations.py index a4420762a932..0e81641c4329 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/operations/_data_collection_rules_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/operations/_data_collection_rules_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,9 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str + api_version: Literal["2019-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-11-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -55,7 +62,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -70,7 +77,9 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str + api_version: Literal["2019-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-11-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -81,7 +90,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -98,7 +107,9 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str + api_version: Literal["2019-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-11-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -114,7 +125,7 @@ def build_get_request( "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -131,8 +142,10 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2019-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -148,7 +161,7 @@ def build_create_request( "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -167,8 +180,10 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2019-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -184,7 +199,7 @@ def build_update_request( "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -203,7 +218,9 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str + api_version: Literal["2019-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-11-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -219,7 +236,7 @@ def build_delete_request( "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -270,8 +287,10 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResourceListResult] + api_version: Literal["2019-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-11-01-preview") + ) + cls: ClsType[_models.DataCollectionRuleResourceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -293,16 +312,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -310,13 +336,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("DataCollectionRuleResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -330,7 +356,9 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules" + } @distributed_trace def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.DataCollectionRuleResource"]: @@ -348,8 +376,10 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.DataCollectio _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResourceListResult] + api_version: Literal["2019-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-11-01-preview") + ) + cls: ClsType[_models.DataCollectionRuleResourceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -370,16 +400,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -387,13 +424,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("DataCollectionRuleResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -407,7 +444,9 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionRules"} # type: ignore + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionRules" + } @distributed_trace def get( @@ -439,8 +478,10 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResource] + api_version: Literal["2019-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-11-01-preview") + ) + cls: ClsType[_models.DataCollectionRuleResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -452,9 +493,9 @@ def get( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -472,7 +513,9 @@ def get( return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" + } @overload def create( @@ -554,7 +597,8 @@ def create( :param data_collection_rule_name: The name of the data collection rule. The name is case insensitive. Required. :type data_collection_rule_name: str - :param body: The payload. Is either a model type or a IO type. Default value is None. + :param body: The payload. Is either a DataCollectionRuleResource type or a IO type. Default + value is None. :type body: ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -576,9 +620,11 @@ def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResource] + api_version: Literal["2019-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataCollectionRuleResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -604,9 +650,9 @@ def create( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -624,11 +670,13 @@ def create( deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore + create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" + } @overload def update( @@ -710,7 +758,8 @@ def update( :param data_collection_rule_name: The name of the data collection rule. The name is case insensitive. Required. :type data_collection_rule_name: str - :param body: The payload. Is either a model type or a IO type. Default value is None. + :param body: The payload. Is either a ResourceForUpdate type or a IO type. Default value is + None. :type body: ~$(python-base-namespace).v2019_11_01_preview.models.ResourceForUpdate or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -731,9 +780,11 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResource] + api_version: Literal["2019-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-11-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataCollectionRuleResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -759,9 +810,9 @@ def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -779,7 +830,9 @@ def update( return deserialized - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -811,8 +864,10 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2019-11-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2019-11-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -824,9 +879,9 @@ def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -840,4 +895,6 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/__init__.py index 8ba4823444a9..2c7733bfd566 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/__init__.py @@ -13,12 +13,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["MonitorManagementClient"] +__all__ = [ + "MonitorManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_configuration.py index 6769079daccf..a051a0ea24f5 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -34,7 +40,7 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2020-01-01-preview") # type: str + api_version: Literal["2020-01-01-preview"] = kwargs.pop("api_version", "2020-01-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -45,10 +51,7 @@ def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, **kwargs # type: Any - ): - # type: (...) -> None + def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_metadata.json index bf8fca7f72ca..3c94faf452bf 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_metadata.json @@ -19,7 +19,8 @@ "signature": "credential: \"TokenCredential\",", "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true + "required": true, + "method_location": "positional" } }, "async": { @@ -36,22 +37,25 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "signature": "api_version: Optional[str]=None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } }, "async": { @@ -59,19 +63,22 @@ "signature": "api_version: Optional[str] = None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { "signature": "profile: KnownProfiles = KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } } } @@ -87,4 +94,4 @@ "operation_groups": { "management_group_diagnostic_settings": "ManagementGroupDiagnosticSettingsOperations" } -} \ No newline at end of file +} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_monitor_management_client.py index 19296b7e4e2a..dfd1b284dbfa 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_monitor_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from . import models +from . import models as _models from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ManagementGroupDiagnosticSettingsOperations @@ -44,7 +44,7 @@ def __init__( self._config = MonitorManagementClientConfiguration(credential=credential, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -74,15 +74,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> MonitorManagementClient + def __enter__(self) -> "MonitorManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_vendor.py index 9aad73fc743e..bd0df84f5319 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_vendor.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_vendor.py @@ -5,6 +5,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import List, cast + from azure.core.pipeline.transport import HttpRequest @@ -22,6 +24,7 @@ def _format_url_section(template, **kwargs): try: return template.format(**kwargs) except KeyError as key: - formatted_components = template.split("/") + # Need the cast, as for some reasons "split" is typed as list[str | Any] + formatted_components = cast(List[str], template.split("/")) components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_version.py index ce9ac7ae37b3..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/__init__.py index 8638dc69d869..2c151bb41c19 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/__init__.py @@ -10,12 +10,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["MonitorManagementClient"] +__all__ = [ + "MonitorManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/_configuration.py index d128e92641dc..740c01dc5e21 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -34,7 +40,7 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2020-01-01-preview") # type: str + api_version: Literal["2020-01-01-preview"] = kwargs.pop("api_version", "2020-01-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/_monitor_management_client.py index de4aa0aec67b..eb9f80715abb 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/_monitor_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from .. import models +from .. import models as _models from ..._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ManagementGroupDiagnosticSettingsOperations @@ -44,7 +44,7 @@ def __init__( self._config = MonitorManagementClientConfiguration(credential=credential, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -81,5 +81,5 @@ async def __aenter__(self) -> "MonitorManagementClient": await self._client.__aenter__() return self - async def __aexit__(self, *exc_details) -> None: + async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/operations/__init__.py index 0a55570458ff..df848453257b 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/operations/__init__.py @@ -9,7 +9,7 @@ from ._management_group_diagnostic_settings_operations import ManagementGroupDiagnosticSettingsOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/operations/_management_group_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/operations/_management_group_diagnostic_settings_operations.py index cec884e74f91..f2ce44ba1ee5 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/operations/_management_group_diagnostic_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/operations/_management_group_diagnostic_settings_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -35,6 +36,10 @@ build_list_request, ) +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -85,8 +90,10 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementGroupDiagnosticSettingsResource] + api_version: Literal["2020-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-01-01-preview") + ) + cls: ClsType[_models.ManagementGroupDiagnosticSettingsResource] = kwargs.pop("cls", None) request = build_get_request( management_group_id=management_group_id, @@ -97,9 +104,9 @@ async def get( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -117,7 +124,9 @@ async def get( return deserialized - get.metadata = {"url": "/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings/{name}"} # type: ignore + get.metadata = { + "url": "/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings/{name}" + } @overload async def create_or_update( @@ -190,8 +199,8 @@ async def create_or_update( :type management_group_id: str :param name: The name of the diagnostic setting. Required. :type name: str - :param parameters: Parameters supplied to the operation. Is either a model type or a IO type. - Required. + :param parameters: Parameters supplied to the operation. Is either a + ManagementGroupDiagnosticSettingsResource type or a IO type. Required. :type parameters: ~$(python-base-namespace).v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResource or IO @@ -215,9 +224,11 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementGroupDiagnosticSettingsResource] + api_version: Literal["2020-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ManagementGroupDiagnosticSettingsResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -239,9 +250,9 @@ async def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -259,7 +270,9 @@ async def create_or_update( return deserialized - create_or_update.metadata = {"url": "/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings/{name}"} # type: ignore + create_or_update.metadata = { + "url": "/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings/{name}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -287,8 +300,10 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2020-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( management_group_id=management_group_id, @@ -299,9 +314,9 @@ async def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -315,7 +330,9 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings/{name}"} # type: ignore + delete.metadata = { + "url": "/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings/{name}" + } @distributed_trace def list( @@ -335,8 +352,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementGroupDiagnosticSettingsResourceCollection] + api_version: Literal["2020-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-01-01-preview") + ) + cls: ClsType[_models.ManagementGroupDiagnosticSettingsResourceCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -357,16 +376,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -374,13 +400,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ManagementGroupDiagnosticSettingsResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -394,4 +420,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings"} # type: ignore + list.metadata = { + "url": "/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/models/__init__.py index 7bd4bf700a00..bb05df8b79ba 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/models/__init__.py @@ -12,7 +12,7 @@ from ._models_py3 import ManagementGroupLogSettings from ._models_py3 import ManagementGroupProxyOnlyResource from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/models/_models_py3.py index 02902c0a3490..60b126be7bda 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/models/_models_py3.py @@ -7,10 +7,14 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, Optional +from typing import Any, List, Optional, TYPE_CHECKING from ... import _serialization +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models + class ErrorResponse(_serialization.Model): """Describes the format of Error response. @@ -26,7 +30,7 @@ class ErrorResponse(_serialization.Model): "message": {"key": "message", "type": "str"}, } - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: """ :keyword code: Error code. :paramtype code: str @@ -66,7 +70,7 @@ class ManagementGroupProxyOnlyResource(_serialization.Model): "location": {"key": "location", "type": "str"}, } - def __init__(self, *, location: Optional[str] = None, **kwargs): + def __init__(self, *, location: Optional[str] = None, **kwargs: Any) -> None: """ :keyword location: Location of the resource. :paramtype location: str @@ -140,8 +144,8 @@ def __init__( event_hub_name: Optional[str] = None, logs: Optional[List["_models.ManagementGroupLogSettings"]] = None, workspace_id: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword location: Location of the resource. :paramtype location: str @@ -185,7 +189,9 @@ class ManagementGroupDiagnosticSettingsResourceCollection(_serialization.Model): "value": {"key": "value", "type": "[ManagementGroupDiagnosticSettingsResource]"}, } - def __init__(self, *, value: Optional[List["_models.ManagementGroupDiagnosticSettingsResource"]] = None, **kwargs): + def __init__( + self, *, value: Optional[List["_models.ManagementGroupDiagnosticSettingsResource"]] = None, **kwargs: Any + ) -> None: """ :keyword value: The collection of management group diagnostic settings resources. :paramtype value: @@ -217,7 +223,7 @@ class ManagementGroupLogSettings(_serialization.Model): "enabled": {"key": "enabled", "type": "bool"}, } - def __init__(self, *, category: str, enabled: bool, **kwargs): + def __init__(self, *, category: str, enabled: bool, **kwargs: Any) -> None: """ :keyword category: Name of a Management Group Diagnostic Log category for a resource type this setting is applied to. Required. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/operations/__init__.py index 0a55570458ff..df848453257b 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/operations/__init__.py @@ -9,7 +9,7 @@ from ._management_group_diagnostic_settings_operations import ManagementGroupDiagnosticSettingsOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/operations/_management_group_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/operations/_management_group_diagnostic_settings_operations.py index 9929a612c7e4..dda715917cb3 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/operations/_management_group_diagnostic_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/operations/_management_group_diagnostic_settings_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,9 @@ def build_get_request(management_group_id: str, name: str, **kwargs: Any) -> Htt _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01-preview")) # type: str + api_version: Literal["2020-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-01-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -53,7 +60,7 @@ def build_get_request(management_group_id: str, name: str, **kwargs: Any) -> Htt "name": _SERIALIZER.url("name", name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -68,8 +75,10 @@ def build_create_or_update_request(management_group_id: str, name: str, **kwargs _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2020-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -82,7 +91,7 @@ def build_create_or_update_request(management_group_id: str, name: str, **kwargs "name": _SERIALIZER.url("name", name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -99,7 +108,9 @@ def build_delete_request(management_group_id: str, name: str, **kwargs: Any) -> _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01-preview")) # type: str + api_version: Literal["2020-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-01-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -112,7 +123,7 @@ def build_delete_request(management_group_id: str, name: str, **kwargs: Any) -> "name": _SERIALIZER.url("name", name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -127,7 +138,9 @@ def build_list_request(management_group_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01-preview")) # type: str + api_version: Literal["2020-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-01-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -139,7 +152,7 @@ def build_list_request(management_group_id: str, **kwargs: Any) -> HttpRequest: "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str", skip_quote=True), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -196,8 +209,10 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementGroupDiagnosticSettingsResource] + api_version: Literal["2020-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-01-01-preview") + ) + cls: ClsType[_models.ManagementGroupDiagnosticSettingsResource] = kwargs.pop("cls", None) request = build_get_request( management_group_id=management_group_id, @@ -208,9 +223,9 @@ def get( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -228,7 +243,9 @@ def get( return deserialized - get.metadata = {"url": "/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings/{name}"} # type: ignore + get.metadata = { + "url": "/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings/{name}" + } @overload def create_or_update( @@ -301,8 +318,8 @@ def create_or_update( :type management_group_id: str :param name: The name of the diagnostic setting. Required. :type name: str - :param parameters: Parameters supplied to the operation. Is either a model type or a IO type. - Required. + :param parameters: Parameters supplied to the operation. Is either a + ManagementGroupDiagnosticSettingsResource type or a IO type. Required. :type parameters: ~$(python-base-namespace).v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResource or IO @@ -326,9 +343,11 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementGroupDiagnosticSettingsResource] + api_version: Literal["2020-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-01-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ManagementGroupDiagnosticSettingsResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -350,9 +369,9 @@ def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -370,7 +389,9 @@ def create_or_update( return deserialized - create_or_update.metadata = {"url": "/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings/{name}"} # type: ignore + create_or_update.metadata = { + "url": "/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings/{name}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -398,8 +419,10 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2020-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-01-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( management_group_id=management_group_id, @@ -410,9 +433,9 @@ def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -426,7 +449,9 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings/{name}"} # type: ignore + delete.metadata = { + "url": "/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings/{name}" + } @distributed_trace def list( @@ -446,8 +471,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementGroupDiagnosticSettingsResourceCollection] + api_version: Literal["2020-01-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-01-01-preview") + ) + cls: ClsType[_models.ManagementGroupDiagnosticSettingsResourceCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -468,16 +495,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -485,13 +519,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ManagementGroupDiagnosticSettingsResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -505,4 +539,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings"} # type: ignore + list.metadata = { + "url": "/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/__init__.py index 8ba4823444a9..2c7733bfd566 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/__init__.py @@ -13,12 +13,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["MonitorManagementClient"] +__all__ = [ + "MonitorManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_configuration.py index e6cba4ff262e..0c9435092a06 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -36,7 +42,7 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2020-05-01-preview") # type: str + api_version: Literal["2020-05-01-preview"] = kwargs.pop("api_version", "2020-05-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -50,10 +56,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, **kwargs # type: Any - ): - # type: (...) -> None + def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_metadata.json index e7e8fcaa5297..660ad49963d5 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_metadata.json @@ -19,13 +19,15 @@ "signature": "credential: \"TokenCredential\",", "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true + "required": true, + "method_location": "positional" }, "subscription_id": { "signature": "subscription_id: str,", "description": "The ID of the target subscription. Required.", "docstring_type": "str", - "required": true + "required": true, + "method_location": "positional" } }, "async": { @@ -48,22 +50,25 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "signature": "api_version: Optional[str]=None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } }, "async": { @@ -71,19 +76,22 @@ "signature": "api_version: Optional[str] = None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { "signature": "profile: KnownProfiles = KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } } } @@ -99,4 +107,4 @@ "operation_groups": { "scheduled_query_rules": "ScheduledQueryRulesOperations" } -} \ No newline at end of file +} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_monitor_management_client.py index 8147bee343a0..000960273ac7 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_monitor_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from . import models +from . import models as _models from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ScheduledQueryRulesOperations @@ -51,7 +51,7 @@ def __init__( ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -81,15 +81,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> MonitorManagementClient + def __enter__(self) -> "MonitorManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_vendor.py index 9aad73fc743e..bd0df84f5319 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_vendor.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_vendor.py @@ -5,6 +5,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import List, cast + from azure.core.pipeline.transport import HttpRequest @@ -22,6 +24,7 @@ def _format_url_section(template, **kwargs): try: return template.format(**kwargs) except KeyError as key: - formatted_components = template.split("/") + # Need the cast, as for some reasons "split" is typed as list[str | Any] + formatted_components = cast(List[str], template.split("/")) components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_version.py index ce9ac7ae37b3..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/__init__.py index 8638dc69d869..2c151bb41c19 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/__init__.py @@ -10,12 +10,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["MonitorManagementClient"] +__all__ = [ + "MonitorManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/_configuration.py index 0431945b030f..2cb0cf71f8ae 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -36,7 +42,7 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2020-05-01-preview") # type: str + api_version: Literal["2020-05-01-preview"] = kwargs.pop("api_version", "2020-05-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/_monitor_management_client.py index 07701fad49a3..9162a602f799 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/_monitor_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from .. import models +from .. import models as _models from ..._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ScheduledQueryRulesOperations @@ -51,7 +51,7 @@ def __init__( ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -88,5 +88,5 @@ async def __aenter__(self) -> "MonitorManagementClient": await self._client.__aenter__() return self - async def __aexit__(self, *exc_details) -> None: + async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/operations/__init__.py index 40cd07056c01..e010c281d4fc 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/operations/__init__.py @@ -9,7 +9,7 @@ from ._scheduled_query_rules_operations import ScheduledQueryRulesOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/operations/_scheduled_query_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/operations/_scheduled_query_rules_operations.py index 0356bcab1a81..e69d39e3e589 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/operations/_scheduled_query_rules_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/operations/_scheduled_query_rules_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -37,6 +38,10 @@ build_update_request, ) +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -74,8 +79,10 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.Schedule _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ScheduledQueryRuleResourceCollection] + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.ScheduledQueryRuleResourceCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -96,16 +103,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -113,13 +127,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ScheduledQueryRuleResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -133,7 +147,9 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/scheduledQueryRules"} # type: ignore + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/scheduledQueryRules" + } @distributed_trace def list_by_resource_group( @@ -154,8 +170,10 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ScheduledQueryRuleResourceCollection] + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.ScheduledQueryRuleResourceCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -177,16 +195,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -194,13 +219,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ScheduledQueryRuleResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -214,7 +239,9 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules" + } @distributed_trace_async async def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _models.ScheduledQueryRuleResource: @@ -241,8 +268,10 @@ async def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ScheduledQueryRuleResource] + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.ScheduledQueryRuleResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -254,9 +283,9 @@ async def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -274,7 +303,9 @@ async def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}" + } @overload async def create_or_update( @@ -348,8 +379,8 @@ async def create_or_update( :type resource_group_name: str :param rule_name: The name of the rule. Required. :type rule_name: str - :param parameters: The parameters of the rule to create or update. Is either a model type or a - IO type. Required. + :param parameters: The parameters of the rule to create or update. Is either a + ScheduledQueryRuleResource type or a IO type. Required. :type parameters: ~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -371,9 +402,11 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ScheduledQueryRuleResource] + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScheduledQueryRuleResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -396,9 +429,9 @@ async def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -416,11 +449,13 @@ async def create_or_update( deserialized = self._deserialize("ScheduledQueryRuleResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}" + } @overload async def update( @@ -494,8 +529,8 @@ async def update( :type resource_group_name: str :param rule_name: The name of the rule. Required. :type rule_name: str - :param parameters: The parameters of the rule to update. Is either a model type or a IO type. - Required. + :param parameters: The parameters of the rule to update. Is either a + ScheduledQueryRuleResourcePatch type or a IO type. Required. :type parameters: ~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResourcePatch or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -517,9 +552,11 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ScheduledQueryRuleResource] + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScheduledQueryRuleResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -542,9 +579,9 @@ async def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -562,7 +599,9 @@ async def update( return deserialized - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -591,8 +630,10 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -604,9 +645,9 @@ async def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -620,4 +661,6 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/__init__.py index 2cae1c6fc22b..808b00e8d2db 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/__init__.py @@ -25,7 +25,7 @@ from ._monitor_management_client_enums import DimensionOperator from ._monitor_management_client_enums import TimeAggregation from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/_models_py3.py index e2dc856d2c62..a94da047d5d1 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/_models_py3.py @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, TYPE_CHECKING, Union +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union from ... import _serialization @@ -32,8 +32,12 @@ class Action(_serialization.Model): } def __init__( - self, *, action_group_id: Optional[str] = None, web_hook_properties: Optional[Dict[str, str]] = None, **kwargs - ): + self, + *, + action_group_id: Optional[str] = None, + web_hook_properties: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> None: """ :keyword action_group_id: Action Group resource Id to invoke when the alert fires. :paramtype action_group_id: str @@ -103,8 +107,8 @@ def __init__( resource_id_column: Optional[str] = None, dimensions: Optional[List["_models.Dimension"]] = None, failing_periods: Optional["_models.ConditionFailingPeriods"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword query: Log query alert. :paramtype query: str @@ -142,7 +146,8 @@ def __init__( class ConditionFailingPeriods(_serialization.Model): - """The minimum number of violations required within the selected lookback time window required to raise an alert. + """The minimum number of violations required within the selected lookback time window required to + raise an alert. :ivar number_of_evaluation_periods: The number of aggregated lookback points. The lookback time window is calculated based on the aggregation granularity (windowSize) and the selected number @@ -158,7 +163,9 @@ class ConditionFailingPeriods(_serialization.Model): "min_failing_periods_to_alert": {"key": "minFailingPeriodsToAlert", "type": "int"}, } - def __init__(self, *, number_of_evaluation_periods: int = 1, min_failing_periods_to_alert: int = 1, **kwargs): + def __init__( + self, *, number_of_evaluation_periods: int = 1, min_failing_periods_to_alert: int = 1, **kwargs: Any + ) -> None: """ :keyword number_of_evaluation_periods: The number of aggregated lookback points. The lookback time window is calculated based on the aggregation granularity (windowSize) and the selected @@ -200,7 +207,9 @@ class Dimension(_serialization.Model): "values": {"key": "values", "type": "[str]"}, } - def __init__(self, *, name: str, operator: Union[str, "_models.DimensionOperator"], values: List[str], **kwargs): + def __init__( + self, *, name: str, operator: Union[str, "_models.DimensionOperator"], values: List[str], **kwargs: Any + ) -> None: """ :keyword name: Name of the dimension. Required. :paramtype name: str @@ -238,7 +247,7 @@ class ErrorAdditionalInfo(_serialization.Model): "info": {"key": "info", "type": "object"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.type = None @@ -256,7 +265,7 @@ class ErrorContract(_serialization.Model): "error": {"key": "error", "type": "ErrorResponse"}, } - def __init__(self, *, error: Optional["_models.ErrorResponse"] = None, **kwargs): + def __init__(self, *, error: Optional["_models.ErrorResponse"] = None, **kwargs: Any) -> None: """ :keyword error: The error details. :paramtype error: ~$(python-base-namespace).v2020_05_01_preview.models.ErrorResponse @@ -266,7 +275,8 @@ def __init__(self, *, error: Optional["_models.ErrorResponse"] = None, **kwargs) 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.). + """Common error response for all Azure Resource Manager APIs to return error details for failed + operations. (This also follows the OData error response format.). Variables are only populated by the server, and will be ignored when sending a request. @@ -299,7 +309,7 @@ class ErrorResponse(_serialization.Model): "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.code = None @@ -336,7 +346,7 @@ class Resource(_serialization.Model): "type": {"key": "type", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.id = None @@ -355,7 +365,7 @@ class ScheduledQueryRuleCriteria(_serialization.Model): "all_of": {"key": "allOf", "type": "[Condition]"}, } - def __init__(self, *, all_of: Optional[List["_models.Condition"]] = None, **kwargs): + def __init__(self, *, all_of: Optional[List["_models.Condition"]] = None, **kwargs: Any) -> None: """ :keyword all_of: A list of conditions to evaluate against the specified scopes. :paramtype all_of: list[~$(python-base-namespace).v2020_05_01_preview.models.Condition] @@ -365,7 +375,8 @@ def __init__(self, *, all_of: Optional[List["_models.Condition"]] = None, **kwar class TrackedResource(Resource): - """The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location'. + """The resource model definition for an Azure Resource Manager tracked top level resource which + has 'tags' and a 'location'. Variables are only populated by the server, and will be ignored when sending a request. @@ -400,7 +411,7 @@ class TrackedResource(Resource): "location": {"key": "location", "type": "str"}, } - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: """ :keyword tags: Resource tags. :paramtype tags: dict[str, str] @@ -533,8 +544,8 @@ def __init__( criteria: Optional["_models.ScheduledQueryRuleCriteria"] = None, mute_actions_duration: Optional[datetime.timedelta] = None, actions: Optional[List["_models.Action"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword tags: Resource tags. :paramtype tags: dict[str, str] @@ -607,7 +618,7 @@ class ScheduledQueryRuleResourceCollection(_serialization.Model): "value": {"key": "value", "type": "[ScheduledQueryRuleResource]"}, } - def __init__(self, *, value: Optional[List["_models.ScheduledQueryRuleResource"]] = None, **kwargs): + def __init__(self, *, value: Optional[List["_models.ScheduledQueryRuleResource"]] = None, **kwargs: Any) -> None: """ :keyword value: The values for the scheduled query rule resources. :paramtype value: @@ -703,8 +714,8 @@ def __init__( criteria: Optional["_models.ScheduledQueryRuleCriteria"] = None, mute_actions_duration: Optional[datetime.timedelta] = None, actions: Optional[List["_models.Action"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword tags: Resource tags. :paramtype tags: dict[str, str] diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/operations/__init__.py index 40cd07056c01..e010c281d4fc 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/operations/__init__.py @@ -9,7 +9,7 @@ from ._scheduled_query_rules_operations import ScheduledQueryRulesOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/operations/_scheduled_query_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/operations/_scheduled_query_rules_operations.py index 8675865e5e86..de2dbd8114ff 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/operations/_scheduled_query_rules_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/operations/_scheduled_query_rules_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,9 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01-preview")) # type: str + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -51,7 +58,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -66,7 +73,9 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01-preview")) # type: str + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -81,7 +90,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -96,7 +105,9 @@ def build_get_request(resource_group_name: str, rule_name: str, subscription_id: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01-preview")) # type: str + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -112,7 +123,7 @@ def build_get_request(resource_group_name: str, rule_name: str, subscription_id: "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -129,8 +140,10 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -146,7 +159,7 @@ def build_create_or_update_request( "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -163,8 +176,10 @@ def build_update_request(resource_group_name: str, rule_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -180,7 +195,7 @@ def build_update_request(resource_group_name: str, rule_name: str, subscription_ "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -197,7 +212,9 @@ def build_delete_request(resource_group_name: str, rule_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01-preview")) # type: str + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -213,7 +230,7 @@ def build_delete_request(resource_group_name: str, rule_name: str, subscription_ "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -257,8 +274,10 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.ScheduledQuer _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ScheduledQueryRuleResourceCollection] + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.ScheduledQueryRuleResourceCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -279,16 +298,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -296,13 +322,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ScheduledQueryRuleResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -316,7 +342,9 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/scheduledQueryRules"} # type: ignore + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/scheduledQueryRules" + } @distributed_trace def list_by_resource_group( @@ -337,8 +365,10 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ScheduledQueryRuleResourceCollection] + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.ScheduledQueryRuleResourceCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -360,16 +390,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -377,13 +414,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ScheduledQueryRuleResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -397,7 +434,9 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules" + } @distributed_trace def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _models.ScheduledQueryRuleResource: @@ -424,8 +463,10 @@ def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _model _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ScheduledQueryRuleResource] + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[_models.ScheduledQueryRuleResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -437,9 +478,9 @@ def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _model params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -457,7 +498,9 @@ def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _model return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}" + } @overload def create_or_update( @@ -531,8 +574,8 @@ def create_or_update( :type resource_group_name: str :param rule_name: The name of the rule. Required. :type rule_name: str - :param parameters: The parameters of the rule to create or update. Is either a model type or a - IO type. Required. + :param parameters: The parameters of the rule to create or update. Is either a + ScheduledQueryRuleResource type or a IO type. Required. :type parameters: ~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -554,9 +597,11 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ScheduledQueryRuleResource] + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScheduledQueryRuleResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -579,9 +624,9 @@ def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -599,11 +644,13 @@ def create_or_update( deserialized = self._deserialize("ScheduledQueryRuleResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}" + } @overload def update( @@ -677,8 +724,8 @@ def update( :type resource_group_name: str :param rule_name: The name of the rule. Required. :type rule_name: str - :param parameters: The parameters of the rule to update. Is either a model type or a IO type. - Required. + :param parameters: The parameters of the rule to update. Is either a + ScheduledQueryRuleResourcePatch type or a IO type. Required. :type parameters: ~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResourcePatch or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -700,9 +747,11 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ScheduledQueryRuleResource] + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScheduledQueryRuleResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -725,9 +774,9 @@ def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -745,7 +794,9 @@ def update( return deserialized - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -774,8 +825,10 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2020-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2020-05-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -787,9 +840,9 @@ def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -803,4 +856,6 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/__init__.py index 8ba4823444a9..2c7733bfd566 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/__init__.py @@ -13,12 +13,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["MonitorManagementClient"] +__all__ = [ + "MonitorManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_configuration.py index b26fd7e5ea92..925eb3a2ad0f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -36,7 +42,7 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2020-10-01") # type: str + api_version: Literal["2020-10-01"] = kwargs.pop("api_version", "2020-10-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -50,10 +56,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, **kwargs # type: Any - ): - # type: (...) -> None + def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_metadata.json index 95a4e46d1b8a..8310acd4e00c 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_metadata.json @@ -19,13 +19,15 @@ "signature": "credential: \"TokenCredential\",", "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true + "required": true, + "method_location": "positional" }, "subscription_id": { "signature": "subscription_id: str,", "description": "The ID of the target subscription. Required.", "docstring_type": "str", - "required": true + "required": true, + "method_location": "positional" } }, "async": { @@ -48,22 +50,25 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "signature": "api_version: Optional[str]=None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } }, "async": { @@ -71,19 +76,22 @@ "signature": "api_version: Optional[str] = None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { "signature": "profile: KnownProfiles = KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } } } @@ -99,4 +107,4 @@ "operation_groups": { "activity_log_alerts": "ActivityLogAlertsOperations" } -} \ No newline at end of file +} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_monitor_management_client.py index 83b34dd8a854..29efa6ca7d5b 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_monitor_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from . import models +from . import models as _models from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ActivityLogAlertsOperations @@ -51,7 +51,7 @@ def __init__( ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -81,15 +81,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> MonitorManagementClient + def __enter__(self) -> "MonitorManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_vendor.py index 9aad73fc743e..bd0df84f5319 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_vendor.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_vendor.py @@ -5,6 +5,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import List, cast + from azure.core.pipeline.transport import HttpRequest @@ -22,6 +24,7 @@ def _format_url_section(template, **kwargs): try: return template.format(**kwargs) except KeyError as key: - formatted_components = template.split("/") + # Need the cast, as for some reasons "split" is typed as list[str | Any] + formatted_components = cast(List[str], template.split("/")) components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_version.py index ce9ac7ae37b3..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/__init__.py index 8638dc69d869..2c151bb41c19 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/__init__.py @@ -10,12 +10,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["MonitorManagementClient"] +__all__ = [ + "MonitorManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/_configuration.py index b677dfda241d..15ad289ba9ca 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -36,7 +42,7 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2020-10-01") # type: str + api_version: Literal["2020-10-01"] = kwargs.pop("api_version", "2020-10-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/_monitor_management_client.py index 74f37766599e..8ab07eb90389 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/_monitor_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from .. import models +from .. import models as _models from ..._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ActivityLogAlertsOperations @@ -51,7 +51,7 @@ def __init__( ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -88,5 +88,5 @@ async def __aenter__(self) -> "MonitorManagementClient": await self._client.__aenter__() return self - async def __aexit__(self, *exc_details) -> None: + async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/operations/__init__.py index 605798ce7feb..b024a2af0682 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/operations/__init__.py @@ -9,7 +9,7 @@ from ._activity_log_alerts_operations import ActivityLogAlertsOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/operations/_activity_log_alerts_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/operations/_activity_log_alerts_operations.py index 718cf778446e..13b495ca9460 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/operations/_activity_log_alerts_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/operations/_activity_log_alerts_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -37,6 +38,10 @@ build_update_request, ) +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -135,7 +140,7 @@ async def create_or_update( :param activity_log_alert_name: The name of the Activity Log Alert rule. Required. :type activity_log_alert_name: str :param activity_log_alert_rule: The Activity Log Alert rule to create or use for the update. Is - either a model type or a IO type. Required. + either a ActivityLogAlertResource type or a IO type. Required. :type activity_log_alert_rule: ~$(python-base-namespace).v2020_10_01.models.ActivityLogAlertResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -157,9 +162,9 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActivityLogAlertResource] + api_version: Literal["2020-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ActivityLogAlertResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -182,9 +187,9 @@ async def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -202,11 +207,13 @@ async def create_or_update( deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}" + } @distributed_trace_async async def get( @@ -235,8 +242,8 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActivityLogAlertResource] + api_version: Literal["2020-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) + cls: ClsType[_models.ActivityLogAlertResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -248,9 +255,9 @@ async def get( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -268,7 +275,9 @@ async def get( return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -297,8 +306,8 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2020-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -310,9 +319,9 @@ async def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -326,7 +335,9 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}" + } @overload async def update( @@ -406,8 +417,8 @@ async def update( :type resource_group_name: str :param activity_log_alert_name: The name of the Activity Log Alert rule. Required. :type activity_log_alert_name: str - :param activity_log_alert_rule_patch: Parameters supplied to the operation. Is either a model - type or a IO type. Required. + :param activity_log_alert_rule_patch: Parameters supplied to the operation. Is either a + AlertRulePatchObject type or a IO type. Required. :type activity_log_alert_rule_patch: ~$(python-base-namespace).v2020_10_01.models.AlertRulePatchObject or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -429,9 +440,9 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActivityLogAlertResource] + api_version: Literal["2020-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ActivityLogAlertResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -454,9 +465,9 @@ async def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -474,7 +485,9 @@ async def update( return deserialized - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}" + } @distributed_trace def list_by_subscription_id(self, **kwargs: Any) -> AsyncIterable["_models.ActivityLogAlertResource"]: @@ -490,8 +503,8 @@ def list_by_subscription_id(self, **kwargs: Any) -> AsyncIterable["_models.Activ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleList] + api_version: Literal["2020-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) + cls: ClsType[_models.AlertRuleList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -512,16 +525,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -529,13 +549,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("AlertRuleList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -549,7 +569,9 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_subscription_id.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/activityLogAlerts"} # type: ignore + list_by_subscription_id.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/activityLogAlerts" + } @distributed_trace def list_by_resource_group( @@ -570,8 +592,8 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleList] + api_version: Literal["2020-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) + cls: ClsType[_models.AlertRuleList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -593,16 +615,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -610,13 +639,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("AlertRuleList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -630,4 +659,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/__init__.py index 6f14c5c24a84..68b921674c5d 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/__init__.py @@ -17,7 +17,7 @@ from ._models_py3 import AzureResource from ._models_py3 import ErrorResponse from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/_models_py3.py index ef4dee4fd3f8..b63f24d95909 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/_models_py3.py @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Dict, List, Optional, TYPE_CHECKING +from typing import Any, Dict, List, Optional, TYPE_CHECKING from ... import _serialization @@ -38,7 +38,9 @@ class ActionGroup(_serialization.Model): "webhook_properties": {"key": "webhookProperties", "type": "{str}"}, } - def __init__(self, *, action_group_id: str, webhook_properties: Optional[Dict[str, str]] = None, **kwargs): + def __init__( + self, *, action_group_id: str, webhook_properties: Optional[Dict[str, str]] = None, **kwargs: Any + ) -> None: """ :keyword action_group_id: The resource ID of the Action Group. This cannot be null or empty. Required. @@ -63,7 +65,7 @@ class ActionList(_serialization.Model): "action_groups": {"key": "actionGroups", "type": "[ActionGroup]"}, } - def __init__(self, *, action_groups: Optional[List["_models.ActionGroup"]] = None, **kwargs): + def __init__(self, *, action_groups: Optional[List["_models.ActionGroup"]] = None, **kwargs: Any) -> None: """ :keyword action_groups: The list of the Action Groups. :paramtype action_groups: list[~$(python-base-namespace).v2020_10_01.models.ActionGroup] @@ -104,7 +106,7 @@ class AzureResource(_serialization.Model): "tags": {"key": "tags", "type": "{str}"}, } - def __init__(self, *, location: str = "global", tags: Optional[Dict[str, str]] = None, **kwargs): + def __init__(self, *, location: str = "global", tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: """ :keyword location: The location of the resource. Since Azure Activity Log Alerts is a global service, the location of the rules should always be 'global'. @@ -180,8 +182,8 @@ def __init__( actions: Optional["_models.ActionList"] = None, enabled: bool = True, description: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword location: The location of the resource. Since Azure Activity Log Alerts is a global service, the location of the rules should always be 'global'. @@ -228,7 +230,7 @@ class AlertRuleAllOfCondition(_serialization.Model): "all_of": {"key": "allOf", "type": "[AlertRuleAnyOfOrLeafCondition]"}, } - def __init__(self, *, all_of: List["_models.AlertRuleAnyOfOrLeafCondition"], **kwargs): + def __init__(self, *, all_of: List["_models.AlertRuleAnyOfOrLeafCondition"], **kwargs: Any) -> None: """ :keyword all_of: The list of Activity Log Alert rule conditions. Required. :paramtype all_of: @@ -239,20 +241,21 @@ def __init__(self, *, all_of: List["_models.AlertRuleAnyOfOrLeafCondition"], **k class AlertRuleLeafCondition(_serialization.Model): - """An Activity Log Alert rule condition that is met by comparing the field and value of an Activity Log event. + """An Activity Log Alert rule condition that is met by comparing the field and value of an + Activity Log event. This condition must contain 'field' and either 'equals' or 'containsAny'. - :ivar field: The name of the Activity Log event's field that this condition will examine. - The possible values for this field are (case-insensitive): 'resourceId', 'category', 'caller', - 'level', 'operationName', 'resourceGroup', 'resourceProvider', 'status', 'subStatus', - 'resourceType', or anything beginning with 'properties'. - :vartype field: str - :ivar equals: The value of the event's field will be compared to this value (case-insensitive) - to determine if the condition is met. - :vartype equals: str - :ivar contains_any: The value of the event's field will be compared to the values in this array - (case-insensitive) to determine if the condition is met. - :vartype contains_any: list[str] + :ivar field: The name of the Activity Log event's field that this condition will examine. + The possible values for this field are (case-insensitive): 'resourceId', 'category', 'caller', + 'level', 'operationName', 'resourceGroup', 'resourceProvider', 'status', 'subStatus', + 'resourceType', or anything beginning with 'properties'. + :vartype field: str + :ivar equals: The value of the event's field will be compared to this value (case-insensitive) + to determine if the condition is met. + :vartype equals: str + :ivar contains_any: The value of the event's field will be compared to the values in this array + (case-insensitive) to determine if the condition is met. + :vartype contains_any: list[str] """ _attribute_map = { @@ -267,8 +270,8 @@ def __init__( field: Optional[str] = None, equals: Optional[str] = None, contains_any: Optional[List[str]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword field: The name of the Activity Log event's field that this condition will examine. The possible values for this field are (case-insensitive): 'resourceId', 'category', 'caller', @@ -291,29 +294,31 @@ def __init__( class AlertRuleAnyOfOrLeafCondition(AlertRuleLeafCondition): """An Activity Log Alert rule condition that is met when all its member conditions are met. Each condition can be of one of the following types: - **Important**\ : Each type has its unique subset of properties. Properties from different types CANNOT exist in one condition. + **Important**\ : Each type has its unique subset of properties. Properties from different types + CANNOT exist in one condition. * **Leaf Condition -** must contain 'field' and either 'equals' or 'containsAny'. *Please note, 'anyOf' should **not** be set in a Leaf Condition.* * **AnyOf Condition -** must contain **only** 'anyOf' (which is an array of Leaf Conditions). - *Please note, 'field', 'equals' and 'containsAny' should **not** be set in an AnyOf Condition.*. - - :ivar field: The name of the Activity Log event's field that this condition will examine. - The possible values for this field are (case-insensitive): 'resourceId', 'category', 'caller', - 'level', 'operationName', 'resourceGroup', 'resourceProvider', 'status', 'subStatus', - 'resourceType', or anything beginning with 'properties'. - :vartype field: str - :ivar equals: The value of the event's field will be compared to this value (case-insensitive) - to determine if the condition is met. - :vartype equals: str - :ivar contains_any: The value of the event's field will be compared to the values in this array - (case-insensitive) to determine if the condition is met. - :vartype contains_any: list[str] - :ivar any_of: An Activity Log Alert rule condition that is met when at least one of its member - leaf conditions are met. - :vartype any_of: list[~$(python-base-namespace).v2020_10_01.models.AlertRuleLeafCondition] + *Please note, 'field', 'equals' and 'containsAny' should **not** be set in an AnyOf + Condition.*. + + :ivar field: The name of the Activity Log event's field that this condition will examine. + The possible values for this field are (case-insensitive): 'resourceId', 'category', 'caller', + 'level', 'operationName', 'resourceGroup', 'resourceProvider', 'status', 'subStatus', + 'resourceType', or anything beginning with 'properties'. + :vartype field: str + :ivar equals: The value of the event's field will be compared to this value (case-insensitive) + to determine if the condition is met. + :vartype equals: str + :ivar contains_any: The value of the event's field will be compared to the values in this array + (case-insensitive) to determine if the condition is met. + :vartype contains_any: list[str] + :ivar any_of: An Activity Log Alert rule condition that is met when at least one of its member + leaf conditions are met. + :vartype any_of: list[~$(python-base-namespace).v2020_10_01.models.AlertRuleLeafCondition] """ _attribute_map = { @@ -330,8 +335,8 @@ def __init__( equals: Optional[str] = None, contains_any: Optional[List[str]] = None, any_of: Optional[List["_models.AlertRuleLeafCondition"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword field: The name of the Activity Log event's field that this condition will examine. The possible values for this field are (case-insensitive): 'resourceId', 'category', 'caller', @@ -371,8 +376,8 @@ def __init__( *, value: Optional[List["_models.ActivityLogAlertResource"]] = None, next_link: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword value: The list of Activity Log Alert rules. :paramtype value: list[~$(python-base-namespace).v2020_10_01.models.ActivityLogAlertResource] @@ -399,7 +404,7 @@ class AlertRulePatchObject(_serialization.Model): "enabled": {"key": "properties.enabled", "type": "bool"}, } - def __init__(self, *, tags: Optional[Dict[str, str]] = None, enabled: bool = True, **kwargs): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, enabled: bool = True, **kwargs: Any) -> None: """ :keyword tags: The resource tags. :paramtype tags: dict[str, str] @@ -433,7 +438,7 @@ class ErrorResponse(_serialization.Model): "message": {"key": "message", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.code = None diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/operations/__init__.py index 605798ce7feb..b024a2af0682 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/operations/__init__.py @@ -9,7 +9,7 @@ from ._activity_log_alerts_operations import ActivityLogAlertsOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/operations/_activity_log_alerts_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/operations/_activity_log_alerts_operations.py index 37440b16c6e3..88738d078fda 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/operations/_activity_log_alerts_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/operations/_activity_log_alerts_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -42,8 +47,8 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2020-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -59,7 +64,7 @@ def build_create_or_update_request( "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -78,7 +83,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + api_version: Literal["2020-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -94,7 +99,7 @@ def build_get_request( "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -111,7 +116,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + api_version: Literal["2020-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -127,7 +132,7 @@ def build_delete_request( "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -144,8 +149,8 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2020-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -161,7 +166,7 @@ def build_update_request( "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -178,7 +183,7 @@ def build_list_by_subscription_id_request(subscription_id: str, **kwargs: Any) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + api_version: Literal["2020-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -187,7 +192,7 @@ def build_list_by_subscription_id_request(subscription_id: str, **kwargs: Any) - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -202,7 +207,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str + api_version: Literal["2020-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -217,7 +222,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -322,7 +327,7 @@ def create_or_update( :param activity_log_alert_name: The name of the Activity Log Alert rule. Required. :type activity_log_alert_name: str :param activity_log_alert_rule: The Activity Log Alert rule to create or use for the update. Is - either a model type or a IO type. Required. + either a ActivityLogAlertResource type or a IO type. Required. :type activity_log_alert_rule: ~$(python-base-namespace).v2020_10_01.models.ActivityLogAlertResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -344,9 +349,9 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActivityLogAlertResource] + api_version: Literal["2020-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ActivityLogAlertResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -369,9 +374,9 @@ def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -389,11 +394,13 @@ def create_or_update( deserialized = self._deserialize("ActivityLogAlertResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}" + } @distributed_trace def get( @@ -422,8 +429,8 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActivityLogAlertResource] + api_version: Literal["2020-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) + cls: ClsType[_models.ActivityLogAlertResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -435,9 +442,9 @@ def get( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -455,7 +462,9 @@ def get( return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -484,8 +493,8 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2020-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -497,9 +506,9 @@ def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -513,7 +522,9 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}" + } @overload def update( @@ -593,8 +604,8 @@ def update( :type resource_group_name: str :param activity_log_alert_name: The name of the Activity Log Alert rule. Required. :type activity_log_alert_name: str - :param activity_log_alert_rule_patch: Parameters supplied to the operation. Is either a model - type or a IO type. Required. + :param activity_log_alert_rule_patch: Parameters supplied to the operation. Is either a + AlertRulePatchObject type or a IO type. Required. :type activity_log_alert_rule_patch: ~$(python-base-namespace).v2020_10_01.models.AlertRulePatchObject or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -616,9 +627,9 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActivityLogAlertResource] + api_version: Literal["2020-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ActivityLogAlertResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -641,9 +652,9 @@ def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -661,7 +672,9 @@ def update( return deserialized - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}" + } @distributed_trace def list_by_subscription_id(self, **kwargs: Any) -> Iterable["_models.ActivityLogAlertResource"]: @@ -677,8 +690,8 @@ def list_by_subscription_id(self, **kwargs: Any) -> Iterable["_models.ActivityLo _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleList] + api_version: Literal["2020-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) + cls: ClsType[_models.AlertRuleList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -699,16 +712,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -716,13 +736,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("AlertRuleList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -736,7 +756,9 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_subscription_id.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/activityLogAlerts"} # type: ignore + list_by_subscription_id.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/activityLogAlerts" + } @distributed_trace def list_by_resource_group( @@ -757,8 +779,8 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertRuleList] + api_version: Literal["2020-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2020-10-01")) + cls: ClsType[_models.AlertRuleList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -780,16 +802,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -797,13 +826,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("AlertRuleList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -817,4 +846,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/__init__.py index 8ba4823444a9..2c7733bfd566 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/__init__.py @@ -13,12 +13,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["MonitorManagementClient"] +__all__ = [ + "MonitorManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_configuration.py index 4d0e38444d6c..adc1dbfb97de 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -36,7 +42,7 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2021-04-01") # type: str + api_version: Literal["2021-04-01"] = kwargs.pop("api_version", "2021-04-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -50,10 +56,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, **kwargs # type: Any - ): - # type: (...) -> None + def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_metadata.json index 9795233a61a2..9781de4998c9 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_metadata.json @@ -19,13 +19,15 @@ "signature": "credential: \"TokenCredential\",", "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true + "required": true, + "method_location": "positional" }, "subscription_id": { "signature": "subscription_id: str,", "description": "The ID of the target subscription. Required.", "docstring_type": "str", - "required": true + "required": true, + "method_location": "positional" } }, "async": { @@ -48,22 +50,25 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "signature": "api_version: Optional[str]=None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } }, "async": { @@ -71,19 +76,22 @@ "signature": "api_version: Optional[str] = None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { "signature": "profile: KnownProfiles = KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } } } @@ -101,4 +109,4 @@ "data_collection_rule_associations": "DataCollectionRuleAssociationsOperations", "data_collection_rules": "DataCollectionRulesOperations" } -} \ No newline at end of file +} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_monitor_management_client.py index 45b2dc3a676f..929cd39e22e9 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_monitor_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from . import models +from . import models as _models from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ( @@ -61,7 +61,7 @@ def __init__( ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -97,15 +97,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> MonitorManagementClient + def __enter__(self) -> "MonitorManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_vendor.py index 9aad73fc743e..bd0df84f5319 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_vendor.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_vendor.py @@ -5,6 +5,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import List, cast + from azure.core.pipeline.transport import HttpRequest @@ -22,6 +24,7 @@ def _format_url_section(template, **kwargs): try: return template.format(**kwargs) except KeyError as key: - formatted_components = template.split("/") + # Need the cast, as for some reasons "split" is typed as list[str | Any] + formatted_components = cast(List[str], template.split("/")) components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_version.py index ce9ac7ae37b3..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/__init__.py index 8638dc69d869..2c151bb41c19 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/__init__.py @@ -10,12 +10,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["MonitorManagementClient"] +__all__ = [ + "MonitorManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/_configuration.py index 9ce19cb4be68..4b28acf65ca4 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -36,7 +42,7 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2021-04-01") # type: str + api_version: Literal["2021-04-01"] = kwargs.pop("api_version", "2021-04-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/_monitor_management_client.py index f57e156361e1..abd4d117335f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/_monitor_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from .. import models +from .. import models as _models from ..._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ( @@ -61,7 +61,7 @@ def __init__( ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -104,5 +104,5 @@ async def __aenter__(self) -> "MonitorManagementClient": await self._client.__aenter__() return self - async def __aexit__(self, *exc_details) -> None: + async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/__init__.py index 9d11e549f9e4..842046dd09e5 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/__init__.py @@ -11,7 +11,7 @@ from ._data_collection_rules_operations import DataCollectionRulesOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/_data_collection_endpoints_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/_data_collection_endpoints_operations.py index 0e9e8468ff4b..5f0bbd73cc08 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/_data_collection_endpoints_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/_data_collection_endpoints_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -37,6 +38,10 @@ build_update_request, ) +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -81,8 +86,8 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionEndpointResourceListResult] + api_version: Literal["2021-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) + cls: ClsType[_models.DataCollectionEndpointResourceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -104,16 +109,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -121,13 +133,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("DataCollectionEndpointResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -141,7 +153,9 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints" + } @distributed_trace def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.DataCollectionEndpointResource"]: @@ -159,8 +173,8 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.DataColl _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionEndpointResourceListResult] + api_version: Literal["2021-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) + cls: ClsType[_models.DataCollectionEndpointResourceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -181,16 +195,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -198,13 +219,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("DataCollectionEndpointResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -218,7 +239,9 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionEndpoints"} # type: ignore + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionEndpoints" + } @distributed_trace_async async def get( @@ -250,8 +273,8 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionEndpointResource] + api_version: Literal["2021-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) + cls: ClsType[_models.DataCollectionEndpointResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -263,9 +286,9 @@ async def get( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -283,7 +306,9 @@ async def get( return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}" + } @overload async def create( @@ -365,7 +390,8 @@ async def create( :param data_collection_endpoint_name: The name of the data collection endpoint. The name is case insensitive. Required. :type data_collection_endpoint_name: str - :param body: The payload. Is either a model type or a IO type. Default value is None. + :param body: The payload. Is either a DataCollectionEndpointResource type or a IO type. Default + value is None. :type body: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -386,9 +412,9 @@ async def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionEndpointResource] + api_version: Literal["2021-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataCollectionEndpointResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -414,9 +440,9 @@ async def create( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -434,11 +460,13 @@ async def create( deserialized = self._deserialize("DataCollectionEndpointResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}"} # type: ignore + create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}" + } @overload async def update( @@ -520,7 +548,8 @@ async def update( :param data_collection_endpoint_name: The name of the data collection endpoint. The name is case insensitive. Required. :type data_collection_endpoint_name: str - :param body: The payload. Is either a model type or a IO type. Default value is None. + :param body: The payload. Is either a ResourceForUpdate type or a IO type. Default value is + None. :type body: ~$(python-base-namespace).v2021_04_01.models.ResourceForUpdate or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -541,9 +570,9 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionEndpointResource] + api_version: Literal["2021-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataCollectionEndpointResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -569,9 +598,9 @@ async def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -589,7 +618,9 @@ async def update( return deserialized - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -621,8 +652,8 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2021-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -634,9 +665,9 @@ async def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -650,4 +681,6 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/_data_collection_rule_associations_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/_data_collection_rule_associations_operations.py index be82c51962ee..ed6f9f87b034 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/_data_collection_rule_associations_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/_data_collection_rule_associations_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -36,6 +37,10 @@ build_list_by_rule_request, ) +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -79,8 +84,8 @@ def list_by_resource( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] + api_version: Literal["2021-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) + cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -101,16 +106,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -120,13 +132,13 @@ async def extract_data(pipeline_response): ) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -140,7 +152,7 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations"} # type: ignore + list_by_resource.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations"} @distributed_trace def list_by_rule( @@ -166,8 +178,8 @@ def list_by_rule( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] + api_version: Literal["2021-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) + cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -190,16 +202,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -209,13 +228,13 @@ async def extract_data(pipeline_response): ) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -229,7 +248,9 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_rule.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations"} # type: ignore + list_by_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations" + } @distributed_trace_async async def get( @@ -260,8 +281,8 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] + api_version: Literal["2021-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) + cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] = kwargs.pop("cls", None) request = build_get_request( resource_uri=resource_uri, @@ -272,9 +293,9 @@ async def get( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -292,7 +313,9 @@ async def get( return deserialized - get.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore + get.metadata = { + "url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" + } @overload async def create( @@ -371,7 +394,8 @@ async def create( :type resource_uri: str :param association_name: The name of the association. The name is case insensitive. Required. :type association_name: str - :param body: The payload. Is either a model type or a IO type. Default value is None. + :param body: The payload. Is either a DataCollectionRuleAssociationProxyOnlyResource type or a + IO type. Default value is None. :type body: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource or IO @@ -395,9 +419,9 @@ async def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] + api_version: Literal["2021-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -422,9 +446,9 @@ async def create( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -442,11 +466,13 @@ async def create( deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore + create.metadata = { + "url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -476,8 +502,8 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2021-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_uri=resource_uri, @@ -488,9 +514,9 @@ async def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -504,4 +530,6 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore + delete.metadata = { + "url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/_data_collection_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/_data_collection_rules_operations.py index ae37535eb3f4..44bb821c6b3a 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/_data_collection_rules_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/_data_collection_rules_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -37,6 +38,10 @@ build_update_request, ) +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -81,8 +86,8 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResourceListResult] + api_version: Literal["2021-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) + cls: ClsType[_models.DataCollectionRuleResourceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -104,16 +109,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -121,13 +133,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("DataCollectionRuleResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -141,7 +153,9 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules" + } @distributed_trace def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.DataCollectionRuleResource"]: @@ -159,8 +173,8 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.DataColl _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResourceListResult] + api_version: Literal["2021-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) + cls: ClsType[_models.DataCollectionRuleResourceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -181,16 +195,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -198,13 +219,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("DataCollectionRuleResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -218,7 +239,9 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionRules"} # type: ignore + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionRules" + } @distributed_trace_async async def get( @@ -250,8 +273,8 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResource] + api_version: Literal["2021-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) + cls: ClsType[_models.DataCollectionRuleResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -263,9 +286,9 @@ async def get( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -283,7 +306,9 @@ async def get( return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" + } @overload async def create( @@ -365,7 +390,8 @@ async def create( :param data_collection_rule_name: The name of the data collection rule. The name is case insensitive. Required. :type data_collection_rule_name: str - :param body: The payload. Is either a model type or a IO type. Default value is None. + :param body: The payload. Is either a DataCollectionRuleResource type or a IO type. Default + value is None. :type body: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -386,9 +412,9 @@ async def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResource] + api_version: Literal["2021-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataCollectionRuleResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -414,9 +440,9 @@ async def create( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -434,11 +460,13 @@ async def create( deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore + create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" + } @overload async def update( @@ -520,7 +548,8 @@ async def update( :param data_collection_rule_name: The name of the data collection rule. The name is case insensitive. Required. :type data_collection_rule_name: str - :param body: The payload. Is either a model type or a IO type. Default value is None. + :param body: The payload. Is either a ResourceForUpdate type or a IO type. Default value is + None. :type body: ~$(python-base-namespace).v2021_04_01.models.ResourceForUpdate or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -541,9 +570,9 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResource] + api_version: Literal["2021-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataCollectionRuleResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -569,9 +598,9 @@ async def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -589,7 +618,9 @@ async def update( return deserialized - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -621,8 +652,8 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2021-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -634,9 +665,9 @@ async def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -650,4 +681,6 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/__init__.py index 86bd994a6563..69ec359db511 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/__init__.py @@ -60,7 +60,7 @@ from ._monitor_management_client_enums import KnownSyslogDataSourceStreams from ._monitor_management_client_enums import KnownWindowsEventLogDataSourceStreams from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/_models_py3.py index 455717ca16c7..ed6b225af053 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/_models_py3.py @@ -13,13 +13,14 @@ from ... import _serialization -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models if sys.version_info >= (3, 9): from collections.abc import MutableMapping else: from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object @@ -36,7 +37,7 @@ class AzureMonitorMetricsDestination(_serialization.Model): "name": {"key": "name", "type": "str"}, } - def __init__(self, *, name: Optional[str] = None, **kwargs): + def __init__(self, *, name: Optional[str] = None, **kwargs: Any) -> None: """ :keyword name: A friendly name for the destination. This name should be unique across all destinations (regardless of type) within the data @@ -64,7 +65,7 @@ class ConfigurationAccessEndpointSpec(_serialization.Model): "endpoint": {"key": "endpoint", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.endpoint = None @@ -116,8 +117,8 @@ def __init__( configuration_access: Optional["_models.DataCollectionEndpointConfigurationAccess"] = None, logs_ingestion: Optional["_models.DataCollectionEndpointLogsIngestion"] = None, network_acls: Optional["_models.DataCollectionEndpointNetworkAcls"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword description: Description of the data collection endpoint. :paramtype description: str @@ -160,7 +161,7 @@ class DataCollectionEndpointConfigurationAccess(ConfigurationAccessEndpointSpec) "endpoint": {"key": "endpoint", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) @@ -182,7 +183,7 @@ class LogsIngestionEndpointSpec(_serialization.Model): "endpoint": {"key": "endpoint", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.endpoint = None @@ -205,7 +206,7 @@ class DataCollectionEndpointLogsIngestion(LogsIngestionEndpointSpec): "endpoint": {"key": "endpoint", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) @@ -224,8 +225,11 @@ class NetworkRuleSet(_serialization.Model): } def __init__( - self, *, public_network_access: Optional[Union[str, "_models.KnownPublicNetworkAccessOptions"]] = None, **kwargs - ): + self, + *, + public_network_access: Optional[Union[str, "_models.KnownPublicNetworkAccessOptions"]] = None, + **kwargs: Any + ) -> None: """ :keyword public_network_access: The configuration to set whether network access from public internet to the endpoints are allowed. Known values are: "Enabled" and "Disabled". @@ -250,8 +254,11 @@ class DataCollectionEndpointNetworkAcls(NetworkRuleSet): } def __init__( - self, *, public_network_access: Optional[Union[str, "_models.KnownPublicNetworkAccessOptions"]] = None, **kwargs - ): + self, + *, + public_network_access: Optional[Union[str, "_models.KnownPublicNetworkAccessOptions"]] = None, + **kwargs: Any + ) -> None: """ :keyword public_network_access: The configuration to set whether network access from public internet to the endpoints are allowed. Known values are: "Enabled" and "Disabled". @@ -347,8 +354,8 @@ def __init__( configuration_access: Optional["_models.DataCollectionEndpointConfigurationAccess"] = None, logs_ingestion: Optional["_models.DataCollectionEndpointLogsIngestion"] = None, network_acls: Optional["_models.DataCollectionEndpointNetworkAcls"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword location: The geo-location where the resource lives. Required. :paramtype location: str @@ -411,8 +418,8 @@ class DataCollectionEndpointResourceListResult(_serialization.Model): } def __init__( - self, *, value: List["_models.DataCollectionEndpointResource"], next_link: Optional[str] = None, **kwargs - ): + self, *, value: List["_models.DataCollectionEndpointResource"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword value: A list of resources. Required. :paramtype value: @@ -471,8 +478,8 @@ def __init__( configuration_access: Optional["_models.DataCollectionEndpointConfigurationAccess"] = None, logs_ingestion: Optional["_models.DataCollectionEndpointLogsIngestion"] = None, network_acls: Optional["_models.DataCollectionEndpointNetworkAcls"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword description: Description of the data collection endpoint. :paramtype description: str @@ -537,8 +544,8 @@ def __init__( last_modified_by: Optional[str] = None, last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword created_by: The identity that created the resource. :paramtype created_by: str @@ -603,8 +610,8 @@ def __init__( last_modified_by: Optional[str] = None, last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword created_by: The identity that created the resource. :paramtype created_by: str @@ -679,8 +686,8 @@ def __init__( data_sources: Optional["_models.DataCollectionRuleDataSources"] = None, destinations: Optional["_models.DataCollectionRuleDestinations"] = None, data_flows: Optional[List["_models.DataFlow"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword description: Description of the data collection rule. :paramtype description: str @@ -740,8 +747,8 @@ def __init__( description: Optional[str] = None, data_collection_rule_id: Optional[str] = None, data_collection_endpoint_id: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword description: Description of the association. :paramtype description: str @@ -816,8 +823,8 @@ def __init__( description: Optional[str] = None, data_collection_rule_id: Optional[str] = None, data_collection_endpoint_id: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword description: Description of the association. :paramtype description: str @@ -866,8 +873,8 @@ def __init__( *, value: List["_models.DataCollectionRuleAssociationProxyOnlyResource"], next_link: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword value: A list of resources. Required. :paramtype value: @@ -916,8 +923,8 @@ def __init__( description: Optional[str] = None, data_collection_rule_id: Optional[str] = None, data_collection_endpoint_id: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword description: Description of the association. :paramtype description: str @@ -974,8 +981,8 @@ def __init__( last_modified_by: Optional[str] = None, last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword created_by: The identity that created the resource. :paramtype created_by: str @@ -1033,8 +1040,8 @@ def __init__( windows_event_logs: Optional[List["_models.WindowsEventLogDataSource"]] = None, syslog: Optional[List["_models.SyslogDataSource"]] = None, extensions: Optional[List["_models.ExtensionDataSource"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword performance_counters: The list of performance counter data source configurations. :paramtype performance_counters: @@ -1056,18 +1063,19 @@ def __init__( class DataCollectionRuleDataSources(DataSourcesSpec): """The specification of data sources. - This property is optional and can be omitted if the rule is meant to be used via direct calls to the provisioned endpoint. + This property is optional and can be omitted if the rule is meant to be used via direct calls + to the provisioned endpoint. - :ivar performance_counters: The list of performance counter data source configurations. - :vartype performance_counters: - list[~$(python-base-namespace).v2021_04_01.models.PerfCounterDataSource] - :ivar windows_event_logs: The list of Windows Event Log data source configurations. - :vartype windows_event_logs: - list[~$(python-base-namespace).v2021_04_01.models.WindowsEventLogDataSource] - :ivar syslog: The list of Syslog data source configurations. - :vartype syslog: list[~$(python-base-namespace).v2021_04_01.models.SyslogDataSource] - :ivar extensions: The list of Azure VM extension data source configurations. - :vartype extensions: list[~$(python-base-namespace).v2021_04_01.models.ExtensionDataSource] + :ivar performance_counters: The list of performance counter data source configurations. + :vartype performance_counters: + list[~$(python-base-namespace).v2021_04_01.models.PerfCounterDataSource] + :ivar windows_event_logs: The list of Windows Event Log data source configurations. + :vartype windows_event_logs: + list[~$(python-base-namespace).v2021_04_01.models.WindowsEventLogDataSource] + :ivar syslog: The list of Syslog data source configurations. + :vartype syslog: list[~$(python-base-namespace).v2021_04_01.models.SyslogDataSource] + :ivar extensions: The list of Azure VM extension data source configurations. + :vartype extensions: list[~$(python-base-namespace).v2021_04_01.models.ExtensionDataSource] """ _attribute_map = { @@ -1084,8 +1092,8 @@ def __init__( windows_event_logs: Optional[List["_models.WindowsEventLogDataSource"]] = None, syslog: Optional[List["_models.SyslogDataSource"]] = None, extensions: Optional[List["_models.ExtensionDataSource"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword performance_counters: The list of performance counter data source configurations. :paramtype performance_counters: @@ -1128,8 +1136,8 @@ def __init__( *, log_analytics: Optional[List["_models.LogAnalyticsDestination"]] = None, azure_monitor_metrics: Optional["_models.DestinationsSpecAzureMonitorMetrics"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword log_analytics: List of Log Analytics destinations. :paramtype log_analytics: @@ -1164,8 +1172,8 @@ def __init__( *, log_analytics: Optional[List["_models.LogAnalyticsDestination"]] = None, azure_monitor_metrics: Optional["_models.DestinationsSpecAzureMonitorMetrics"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword log_analytics: List of Log Analytics destinations. :paramtype log_analytics: @@ -1260,8 +1268,8 @@ def __init__( data_sources: Optional["_models.DataCollectionRuleDataSources"] = None, destinations: Optional["_models.DataCollectionRuleDestinations"] = None, data_flows: Optional[List["_models.DataFlow"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword location: The geo-location where the resource lives. Required. :paramtype location: str @@ -1320,7 +1328,9 @@ class DataCollectionRuleResourceListResult(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, *, value: List["_models.DataCollectionRuleResource"], next_link: Optional[str] = None, **kwargs): + def __init__( + self, *, value: List["_models.DataCollectionRuleResource"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword value: A list of resources. Required. :paramtype value: list[~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResource] @@ -1378,8 +1388,8 @@ def __init__( data_sources: Optional["_models.DataCollectionRuleDataSources"] = None, destinations: Optional["_models.DataCollectionRuleDestinations"] = None, data_flows: Optional[List["_models.DataFlow"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword description: Description of the data collection rule. :paramtype description: str @@ -1441,8 +1451,8 @@ def __init__( last_modified_by: Optional[str] = None, last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword created_by: The identity that created the resource. :paramtype created_by: str @@ -1491,8 +1501,8 @@ def __init__( *, streams: Optional[List[Union[str, "_models.KnownDataFlowStreams"]]] = None, destinations: Optional[List[str]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword streams: List of streams for this data flow. :paramtype streams: list[str or @@ -1518,7 +1528,7 @@ class DestinationsSpecAzureMonitorMetrics(AzureMonitorMetricsDestination): "name": {"key": "name", "type": "str"}, } - def __init__(self, *, name: Optional[str] = None, **kwargs): + def __init__(self, *, name: Optional[str] = None, **kwargs: Any) -> None: """ :keyword name: A friendly name for the destination. This name should be unique across all destinations (regardless of type) within the data @@ -1549,7 +1559,7 @@ class ErrorAdditionalInfo(_serialization.Model): "info": {"key": "info", "type": "object"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.type = None @@ -1590,7 +1600,7 @@ class ErrorDetail(_serialization.Model): "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.code = None @@ -1601,7 +1611,8 @@ def __init__(self, **kwargs): class ErrorResponseCommonV2(_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.). + """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: ~$(python-base-namespace).v2021_04_01.models.ErrorDetail @@ -1611,7 +1622,7 @@ class ErrorResponseCommonV2(_serialization.Model): "error": {"key": "error", "type": "ErrorDetail"}, } - def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs): + def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: """ :keyword error: The error object. :paramtype error: ~$(python-base-namespace).v2021_04_01.models.ErrorDetail @@ -1621,27 +1632,28 @@ def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs): class ExtensionDataSource(_serialization.Model): - """Definition of which data will be collected from a separate VM extension that integrates with the Azure Monitor Agent. + """Definition of which data will be collected from a separate VM extension that integrates with + the Azure Monitor Agent. Collected from either Windows and Linux machines, depending on which extension is defined. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to Azure. - :ivar streams: List of streams that this data source will be sent to. - A stream indicates what schema will be used for this data and usually what table in Log - Analytics the data will be sent to. - :vartype streams: list[str or - ~$(python-base-namespace).v2021_04_01.models.KnownExtensionDataSourceStreams] - :ivar extension_name: The name of the VM extension. Required. - :vartype extension_name: str - :ivar extension_settings: The extension settings. The format is specific for particular - extension. - :vartype extension_settings: JSON - :ivar input_data_sources: The list of data sources this extension needs data from. - :vartype input_data_sources: list[str] - :ivar name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :vartype name: str + :ivar streams: List of streams that this data source will be sent to. + A stream indicates what schema will be used for this data and usually what table in Log + Analytics the data will be sent to. + :vartype streams: list[str or + ~$(python-base-namespace).v2021_04_01.models.KnownExtensionDataSourceStreams] + :ivar extension_name: The name of the VM extension. Required. + :vartype extension_name: str + :ivar extension_settings: The extension settings. The format is specific for particular + extension. + :vartype extension_settings: JSON + :ivar input_data_sources: The list of data sources this extension needs data from. + :vartype input_data_sources: list[str] + :ivar name: A friendly name for the data source. + This name should be unique across all data sources (regardless of type) within the data + collection rule. + :vartype name: str """ _validation = { @@ -1664,8 +1676,8 @@ def __init__( extension_settings: Optional[JSON] = None, input_data_sources: Optional[List[str]] = None, name: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword streams: List of streams that this data source will be sent to. A stream indicates what schema will be used for this data and usually what table in Log @@ -1717,7 +1729,9 @@ class LogAnalyticsDestination(_serialization.Model): "name": {"key": "name", "type": "str"}, } - def __init__(self, *, workspace_resource_id: Optional[str] = None, name: Optional[str] = None, **kwargs): + def __init__( + self, *, workspace_resource_id: Optional[str] = None, name: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword workspace_resource_id: The resource ID of the Log Analytics workspace. :paramtype workspace_resource_id: str @@ -1733,26 +1747,27 @@ def __init__(self, *, workspace_resource_id: Optional[str] = None, name: Optiona class PerfCounterDataSource(_serialization.Model): - """Definition of which performance counters will be collected and how they will be collected by this data collection rule. + """Definition of which performance counters will be collected and how they will be collected by + this data collection rule. Collected from both Windows and Linux machines where the counter is present. - :ivar streams: List of streams that this data source will be sent to. - A stream indicates what schema will be used for this data and usually what table in Log - Analytics the data will be sent to. - :vartype streams: list[str or - ~$(python-base-namespace).v2021_04_01.models.KnownPerfCounterDataSourceStreams] - :ivar sampling_frequency_in_seconds: The number of seconds between consecutive counter - measurements (samples). - :vartype sampling_frequency_in_seconds: int - :ivar counter_specifiers: A list of specifier names of the performance counters you want to - collect. - Use a wildcard (*) to collect a counter for all instances. - To get a list of performance counters on Windows, run the command 'typeperf'. - :vartype counter_specifiers: list[str] - :ivar name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :vartype name: str + :ivar streams: List of streams that this data source will be sent to. + A stream indicates what schema will be used for this data and usually what table in Log + Analytics the data will be sent to. + :vartype streams: list[str or + ~$(python-base-namespace).v2021_04_01.models.KnownPerfCounterDataSourceStreams] + :ivar sampling_frequency_in_seconds: The number of seconds between consecutive counter + measurements (samples). + :vartype sampling_frequency_in_seconds: int + :ivar counter_specifiers: A list of specifier names of the performance counters you want to + collect. + Use a wildcard (*) to collect a counter for all instances. + To get a list of performance counters on Windows, run the command 'typeperf'. + :vartype counter_specifiers: list[str] + :ivar name: A friendly name for the data source. + This name should be unique across all data sources (regardless of type) within the data + collection rule. + :vartype name: str """ _attribute_map = { @@ -1769,8 +1784,8 @@ def __init__( sampling_frequency_in_seconds: Optional[int] = None, counter_specifiers: Optional[List[str]] = None, name: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword streams: List of streams that this data source will be sent to. A stream indicates what schema will be used for this data and usually what table in Log @@ -1808,7 +1823,7 @@ class ResourceForUpdate(_serialization.Model): "tags": {"key": "tags", "type": "{str}"}, } - def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: """ :keyword tags: Resource tags. :paramtype tags: dict[str, str] @@ -1821,21 +1836,21 @@ class SyslogDataSource(_serialization.Model): """Definition of which syslog data will be collected and how it will be collected. Only collected from Linux machines. - :ivar streams: List of streams that this data source will be sent to. - A stream indicates what schema will be used for this data and usually what table in Log - Analytics the data will be sent to. - :vartype streams: list[str or - ~$(python-base-namespace).v2021_04_01.models.KnownSyslogDataSourceStreams] - :ivar facility_names: The list of facility names. - :vartype facility_names: list[str or - ~$(python-base-namespace).v2021_04_01.models.KnownSyslogDataSourceFacilityNames] - :ivar log_levels: The log levels to collect. - :vartype log_levels: list[str or - ~$(python-base-namespace).v2021_04_01.models.KnownSyslogDataSourceLogLevels] - :ivar name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :vartype name: str + :ivar streams: List of streams that this data source will be sent to. + A stream indicates what schema will be used for this data and usually what table in Log + Analytics the data will be sent to. + :vartype streams: list[str or + ~$(python-base-namespace).v2021_04_01.models.KnownSyslogDataSourceStreams] + :ivar facility_names: The list of facility names. + :vartype facility_names: list[str or + ~$(python-base-namespace).v2021_04_01.models.KnownSyslogDataSourceFacilityNames] + :ivar log_levels: The log levels to collect. + :vartype log_levels: list[str or + ~$(python-base-namespace).v2021_04_01.models.KnownSyslogDataSourceLogLevels] + :ivar name: A friendly name for the data source. + This name should be unique across all data sources (regardless of type) within the data + collection rule. + :vartype name: str """ _attribute_map = { @@ -1852,8 +1867,8 @@ def __init__( facility_names: Optional[List[Union[str, "_models.KnownSyslogDataSourceFacilityNames"]]] = None, log_levels: Optional[List[Union[str, "_models.KnownSyslogDataSourceLogLevels"]]] = None, name: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword streams: List of streams that this data source will be sent to. A stream indicates what schema will be used for this data and usually what table in Log @@ -1882,17 +1897,17 @@ class WindowsEventLogDataSource(_serialization.Model): """Definition of which Windows Event Log events will be collected and how they will be collected. Only collected from Windows machines. - :ivar streams: List of streams that this data source will be sent to. - A stream indicates what schema will be used for this data and usually what table in Log - Analytics the data will be sent to. - :vartype streams: list[str or - ~$(python-base-namespace).v2021_04_01.models.KnownWindowsEventLogDataSourceStreams] - :ivar x_path_queries: A list of Windows Event Log queries in XPATH format. - :vartype x_path_queries: list[str] - :ivar name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :vartype name: str + :ivar streams: List of streams that this data source will be sent to. + A stream indicates what schema will be used for this data and usually what table in Log + Analytics the data will be sent to. + :vartype streams: list[str or + ~$(python-base-namespace).v2021_04_01.models.KnownWindowsEventLogDataSourceStreams] + :ivar x_path_queries: A list of Windows Event Log queries in XPATH format. + :vartype x_path_queries: list[str] + :ivar name: A friendly name for the data source. + This name should be unique across all data sources (regardless of type) within the data + collection rule. + :vartype name: str """ _attribute_map = { @@ -1907,8 +1922,8 @@ def __init__( streams: Optional[List[Union[str, "_models.KnownWindowsEventLogDataSourceStreams"]]] = None, x_path_queries: Optional[List[str]] = None, name: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword streams: List of streams that this data source will be sent to. A stream indicates what schema will be used for this data and usually what table in Log diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/__init__.py index 9d11e549f9e4..842046dd09e5 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/__init__.py @@ -11,7 +11,7 @@ from ._data_collection_rules_operations import DataCollectionRulesOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/_data_collection_endpoints_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/_data_collection_endpoints_operations.py index 92a94672689e..659e3d491b04 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/_data_collection_endpoints_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/_data_collection_endpoints_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + api_version: Literal["2021-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -55,7 +60,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -70,7 +75,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + api_version: Literal["2021-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -81,7 +86,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -98,7 +103,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + api_version: Literal["2021-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -116,7 +121,7 @@ def build_get_request( ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -133,8 +138,8 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2021-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -152,7 +157,7 @@ def build_create_request( ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -171,8 +176,8 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2021-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -190,7 +195,7 @@ def build_update_request( ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -209,7 +214,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + api_version: Literal["2021-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -227,7 +232,7 @@ def build_delete_request( ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -278,8 +283,8 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionEndpointResourceListResult] + api_version: Literal["2021-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) + cls: ClsType[_models.DataCollectionEndpointResourceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -301,16 +306,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -318,13 +330,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("DataCollectionEndpointResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -338,7 +350,9 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints" + } @distributed_trace def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.DataCollectionEndpointResource"]: @@ -356,8 +370,8 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.DataCollectio _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionEndpointResourceListResult] + api_version: Literal["2021-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) + cls: ClsType[_models.DataCollectionEndpointResourceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -378,16 +392,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -395,13 +416,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("DataCollectionEndpointResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -415,7 +436,9 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionEndpoints"} # type: ignore + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionEndpoints" + } @distributed_trace def get( @@ -447,8 +470,8 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionEndpointResource] + api_version: Literal["2021-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) + cls: ClsType[_models.DataCollectionEndpointResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -460,9 +483,9 @@ def get( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -480,7 +503,9 @@ def get( return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}" + } @overload def create( @@ -562,7 +587,8 @@ def create( :param data_collection_endpoint_name: The name of the data collection endpoint. The name is case insensitive. Required. :type data_collection_endpoint_name: str - :param body: The payload. Is either a model type or a IO type. Default value is None. + :param body: The payload. Is either a DataCollectionEndpointResource type or a IO type. Default + value is None. :type body: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -583,9 +609,9 @@ def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionEndpointResource] + api_version: Literal["2021-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataCollectionEndpointResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -611,9 +637,9 @@ def create( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -631,11 +657,13 @@ def create( deserialized = self._deserialize("DataCollectionEndpointResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}"} # type: ignore + create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}" + } @overload def update( @@ -717,7 +745,8 @@ def update( :param data_collection_endpoint_name: The name of the data collection endpoint. The name is case insensitive. Required. :type data_collection_endpoint_name: str - :param body: The payload. Is either a model type or a IO type. Default value is None. + :param body: The payload. Is either a ResourceForUpdate type or a IO type. Default value is + None. :type body: ~$(python-base-namespace).v2021_04_01.models.ResourceForUpdate or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -738,9 +767,9 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionEndpointResource] + api_version: Literal["2021-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataCollectionEndpointResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -766,9 +795,9 @@ def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -786,7 +815,9 @@ def update( return deserialized - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -818,8 +849,8 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2021-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -831,9 +862,9 @@ def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -847,4 +878,6 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/_data_collection_rule_associations_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/_data_collection_rule_associations_operations.py index d457aa3941d8..55ad78307b5d 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/_data_collection_rule_associations_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/_data_collection_rule_associations_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,7 @@ def build_list_by_resource_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 = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + api_version: Literal["2021-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -49,7 +54,7 @@ def build_list_by_resource_request(resource_uri: str, **kwargs: Any) -> HttpRequ "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True, min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -66,7 +71,7 @@ def build_list_by_rule_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + api_version: Literal["2021-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -82,7 +87,7 @@ def build_list_by_rule_request( "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -97,7 +102,7 @@ def build_get_request(resource_uri: str, association_name: str, **kwargs: Any) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + api_version: Literal["2021-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -109,7 +114,7 @@ def build_get_request(resource_uri: str, association_name: str, **kwargs: Any) - "associationName": _SERIALIZER.url("association_name", association_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -124,8 +129,8 @@ def build_create_request(resource_uri: str, association_name: str, **kwargs: Any _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2021-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -137,7 +142,7 @@ def build_create_request(resource_uri: str, association_name: str, **kwargs: Any "associationName": _SERIALIZER.url("association_name", association_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -154,7 +159,7 @@ def build_delete_request(resource_uri: str, association_name: str, **kwargs: Any _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + api_version: Literal["2021-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -166,7 +171,7 @@ def build_delete_request(resource_uri: str, association_name: str, **kwargs: Any "associationName": _SERIALIZER.url("association_name", association_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -216,8 +221,8 @@ def list_by_resource( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] + api_version: Literal["2021-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) + cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -238,16 +243,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -257,13 +269,13 @@ def extract_data(pipeline_response): ) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -277,7 +289,7 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations"} # type: ignore + list_by_resource.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations"} @distributed_trace def list_by_rule( @@ -303,8 +315,8 @@ def list_by_rule( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] + api_version: Literal["2021-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) + cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -327,16 +339,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -346,13 +365,13 @@ def extract_data(pipeline_response): ) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -366,7 +385,9 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_rule.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations"} # type: ignore + list_by_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations" + } @distributed_trace def get( @@ -397,8 +418,8 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] + api_version: Literal["2021-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) + cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] = kwargs.pop("cls", None) request = build_get_request( resource_uri=resource_uri, @@ -409,9 +430,9 @@ def get( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -429,7 +450,9 @@ def get( return deserialized - get.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore + get.metadata = { + "url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" + } @overload def create( @@ -508,7 +531,8 @@ def create( :type resource_uri: str :param association_name: The name of the association. The name is case insensitive. Required. :type association_name: str - :param body: The payload. Is either a model type or a IO type. Default value is None. + :param body: The payload. Is either a DataCollectionRuleAssociationProxyOnlyResource type or a + IO type. Default value is None. :type body: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource or IO @@ -532,9 +556,9 @@ def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] + api_version: Literal["2021-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -559,9 +583,9 @@ def create( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -579,11 +603,13 @@ def create( deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore + create.metadata = { + "url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -613,8 +639,8 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2021-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_uri=resource_uri, @@ -625,9 +651,9 @@ def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -641,4 +667,6 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore + delete.metadata = { + "url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/_data_collection_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/_data_collection_rules_operations.py index 3f4c83d90fea..e428f57ba07a 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/_data_collection_rules_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/_data_collection_rules_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + api_version: Literal["2021-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -55,7 +60,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -70,7 +75,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + api_version: Literal["2021-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -81,7 +86,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -98,7 +103,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + api_version: Literal["2021-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -114,7 +119,7 @@ def build_get_request( "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -131,8 +136,8 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2021-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -148,7 +153,7 @@ def build_create_request( "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -167,8 +172,8 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2021-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -184,7 +189,7 @@ def build_update_request( "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -203,7 +208,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str + api_version: Literal["2021-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -219,7 +224,7 @@ def build_delete_request( "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -270,8 +275,8 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResourceListResult] + api_version: Literal["2021-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) + cls: ClsType[_models.DataCollectionRuleResourceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -293,16 +298,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -310,13 +322,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("DataCollectionRuleResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -330,7 +342,9 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules" + } @distributed_trace def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.DataCollectionRuleResource"]: @@ -348,8 +362,8 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.DataCollectio _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResourceListResult] + api_version: Literal["2021-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) + cls: ClsType[_models.DataCollectionRuleResourceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -370,16 +384,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -387,13 +408,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("DataCollectionRuleResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -407,7 +428,9 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionRules"} # type: ignore + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionRules" + } @distributed_trace def get( @@ -439,8 +462,8 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResource] + api_version: Literal["2021-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) + cls: ClsType[_models.DataCollectionRuleResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -452,9 +475,9 @@ def get( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -472,7 +495,9 @@ def get( return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" + } @overload def create( @@ -554,7 +579,8 @@ def create( :param data_collection_rule_name: The name of the data collection rule. The name is case insensitive. Required. :type data_collection_rule_name: str - :param body: The payload. Is either a model type or a IO type. Default value is None. + :param body: The payload. Is either a DataCollectionRuleResource type or a IO type. Default + value is None. :type body: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -575,9 +601,9 @@ def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResource] + api_version: Literal["2021-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataCollectionRuleResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -603,9 +629,9 @@ def create( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -623,11 +649,13 @@ def create( deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore + create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" + } @overload def update( @@ -709,7 +737,8 @@ def update( :param data_collection_rule_name: The name of the data collection rule. The name is case insensitive. Required. :type data_collection_rule_name: str - :param body: The payload. Is either a model type or a IO type. Default value is None. + :param body: The payload. Is either a ResourceForUpdate type or a IO type. Default value is + None. :type body: ~$(python-base-namespace).v2021_04_01.models.ResourceForUpdate or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -730,9 +759,9 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResource] + api_version: Literal["2021-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataCollectionRuleResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -758,9 +787,9 @@ def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -778,7 +807,9 @@ def update( return deserialized - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -810,8 +841,8 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2021-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -823,9 +854,9 @@ def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -839,4 +870,6 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/__init__.py index 8ba4823444a9..2c7733bfd566 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/__init__.py @@ -13,12 +13,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["MonitorManagementClient"] +__all__ = [ + "MonitorManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_configuration.py index 85a437cbd398..bdecfe75101a 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -36,7 +42,7 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2021-05-01-preview") # type: str + api_version: Literal["2021-05-01-preview"] = kwargs.pop("api_version", "2021-05-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -50,10 +56,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, **kwargs # type: Any - ): - # type: (...) -> None + def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_metadata.json index e9f96dd720ec..f2b273c6bf72 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_metadata.json @@ -19,13 +19,15 @@ "signature": "credential: \"TokenCredential\",", "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true + "required": true, + "method_location": "positional" }, "subscription_id": { "signature": "subscription_id: str,", "description": "The ID of the target subscription. Required.", "docstring_type": "str", - "required": true + "required": true, + "method_location": "positional" } }, "async": { @@ -48,22 +50,25 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "signature": "api_version: Optional[str]=None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } }, "async": { @@ -71,19 +76,22 @@ "signature": "api_version: Optional[str] = None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { "signature": "profile: KnownProfiles = KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } } } @@ -104,4 +112,4 @@ "management_group_diagnostic_settings": "ManagementGroupDiagnosticSettingsOperations", "subscription_diagnostic_settings": "SubscriptionDiagnosticSettingsOperations" } -} \ No newline at end of file +} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_monitor_management_client.py index 301cff76edbc..0037842010b6 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_monitor_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from . import models +from . import models as _models from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ( @@ -74,7 +74,7 @@ def __init__( ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -119,15 +119,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> MonitorManagementClient + def __enter__(self) -> "MonitorManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_vendor.py index 9aad73fc743e..bd0df84f5319 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_vendor.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_vendor.py @@ -5,6 +5,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import List, cast + from azure.core.pipeline.transport import HttpRequest @@ -22,6 +24,7 @@ def _format_url_section(template, **kwargs): try: return template.format(**kwargs) except KeyError as key: - formatted_components = template.split("/") + # Need the cast, as for some reasons "split" is typed as list[str | Any] + formatted_components = cast(List[str], template.split("/")) components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_version.py index ce9ac7ae37b3..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/__init__.py index 8638dc69d869..2c151bb41c19 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/__init__.py @@ -10,12 +10,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["MonitorManagementClient"] +__all__ = [ + "MonitorManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/_configuration.py index 69fc77da4620..9dbd2d527251 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -36,7 +42,7 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2021-05-01-preview") # type: str + api_version: Literal["2021-05-01-preview"] = kwargs.pop("api_version", "2021-05-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/_monitor_management_client.py index 4ebb70bee2d3..27c853501d80 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/_monitor_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from .. import models +from .. import models as _models from ..._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ( @@ -74,7 +74,7 @@ def __init__( ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -126,5 +126,5 @@ async def __aenter__(self) -> "MonitorManagementClient": await self._client.__aenter__() return self - async def __aexit__(self, *exc_details) -> None: + async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/__init__.py index 8ada5606afee..526d8450f6ce 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/__init__.py @@ -14,7 +14,7 @@ from ._subscription_diagnostic_settings_operations import SubscriptionDiagnosticSettingsOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_autoscale_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_autoscale_settings_operations.py index 4f356c76138d..722b9238fbfa 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_autoscale_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_autoscale_settings_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -37,6 +38,10 @@ build_update_request, ) +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -79,8 +84,10 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.AutoscaleSettingResourceCollection] + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[_models.AutoscaleSettingResourceCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -102,16 +109,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -119,13 +133,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("AutoscaleSettingResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -139,7 +153,9 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings" + } @overload async def create_or_update( @@ -212,8 +228,8 @@ async def create_or_update( :type resource_group_name: str :param autoscale_setting_name: The autoscale setting name. Required. :type autoscale_setting_name: str - :param parameters: Parameters supplied to the operation. Is either a model type or a IO type. - Required. + :param parameters: Parameters supplied to the operation. Is either a AutoscaleSettingResource + type or a IO type. Required. :type parameters: ~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -235,9 +251,11 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.AutoscaleSettingResource] + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AutoscaleSettingResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -260,9 +278,9 @@ async def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -280,11 +298,13 @@ async def create_or_update( deserialized = self._deserialize("AutoscaleSettingResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -313,8 +333,10 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -326,9 +348,9 @@ async def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -342,7 +364,9 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}" + } @distributed_trace_async async def get( @@ -371,8 +395,10 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.AutoscaleSettingResource] + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[_models.AutoscaleSettingResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -384,9 +410,9 @@ async def get( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -404,7 +430,9 @@ async def get( return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}" + } @overload async def update( @@ -481,8 +509,8 @@ async def update( :type resource_group_name: str :param autoscale_setting_name: The autoscale setting name. Required. :type autoscale_setting_name: str - :param autoscale_setting_resource: Parameters supplied to the operation. Is either a model type - or a IO type. Required. + :param autoscale_setting_resource: Parameters supplied to the operation. Is either a + AutoscaleSettingResourcePatch type or a IO type. Required. :type autoscale_setting_resource: ~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResourcePatch or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -504,9 +532,11 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.AutoscaleSettingResource] + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AutoscaleSettingResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -529,9 +559,9 @@ async def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -549,7 +579,9 @@ async def update( return deserialized - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}" + } @distributed_trace def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.AutoscaleSettingResource"]: @@ -565,8 +597,10 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.Autoscal _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.AutoscaleSettingResourceCollection] + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[_models.AutoscaleSettingResourceCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -587,16 +621,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -604,13 +645,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("AutoscaleSettingResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -624,4 +665,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/autoscalesettings"} # type: ignore + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/autoscalesettings" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_diagnostic_settings_category_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_diagnostic_settings_category_operations.py index f9dbd6a66bdf..54cd1d010803 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_diagnostic_settings_category_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_diagnostic_settings_category_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -30,6 +31,10 @@ from ..._vendor import _convert_request from ...operations._diagnostic_settings_category_operations import build_get_request, build_list_request +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -77,8 +82,10 @@ async def get(self, resource_uri: str, name: str, **kwargs: Any) -> _models.Diag _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticSettingsCategoryResource] + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[_models.DiagnosticSettingsCategoryResource] = kwargs.pop("cls", None) request = build_get_request( resource_uri=resource_uri, @@ -89,9 +96,9 @@ async def get(self, resource_uri: str, name: str, **kwargs: Any) -> _models.Diag params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -109,7 +116,7 @@ async def get(self, resource_uri: str, name: str, **kwargs: Any) -> _models.Diag return deserialized - get.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories/{name}"} # type: ignore + get.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories/{name}"} @distributed_trace def list(self, resource_uri: str, **kwargs: Any) -> AsyncIterable["_models.DiagnosticSettingsCategoryResource"]: @@ -127,8 +134,10 @@ def list(self, resource_uri: str, **kwargs: Any) -> AsyncIterable["_models.Diagn _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticSettingsCategoryResourceCollection] + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[_models.DiagnosticSettingsCategoryResourceCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -149,16 +158,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -166,13 +182,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("DiagnosticSettingsCategoryResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -186,4 +202,4 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories"} # type: ignore + list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_diagnostic_settings_operations.py index f2308969ef1a..69404d9e7f23 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_diagnostic_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_diagnostic_settings_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -35,6 +36,10 @@ build_list_request, ) +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -82,8 +87,10 @@ async def get(self, resource_uri: str, name: str, **kwargs: Any) -> _models.Diag _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticSettingsResource] + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[_models.DiagnosticSettingsResource] = kwargs.pop("cls", None) request = build_get_request( resource_uri=resource_uri, @@ -94,9 +101,9 @@ async def get(self, resource_uri: str, name: str, **kwargs: Any) -> _models.Diag params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -114,7 +121,7 @@ async def get(self, resource_uri: str, name: str, **kwargs: Any) -> _models.Diag return deserialized - get.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore + get.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} @overload async def create_or_update( @@ -175,8 +182,8 @@ async def create_or_update( :type resource_uri: str :param name: The name of the diagnostic setting. Required. :type name: str - :param parameters: Parameters supplied to the operation. Is either a model type or a IO type. - Required. + :param parameters: Parameters supplied to the operation. Is either a DiagnosticSettingsResource + type or a IO type. Required. :type parameters: ~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -198,9 +205,11 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticSettingsResource] + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DiagnosticSettingsResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -222,9 +231,9 @@ async def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -242,7 +251,7 @@ async def create_or_update( return deserialized - create_or_update.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore + create_or_update.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -270,8 +279,10 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_uri=resource_uri, @@ -282,9 +293,9 @@ async def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -298,7 +309,7 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore + delete.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} @distributed_trace def list(self, resource_uri: str, **kwargs: Any) -> AsyncIterable["_models.DiagnosticSettingsResource"]: @@ -316,8 +327,10 @@ def list(self, resource_uri: str, **kwargs: Any) -> AsyncIterable["_models.Diagn _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticSettingsResourceCollection] + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[_models.DiagnosticSettingsResourceCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -338,16 +351,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -355,13 +375,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("DiagnosticSettingsResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -375,4 +395,4 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings"} # type: ignore + list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_management_group_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_management_group_diagnostic_settings_operations.py index 74816a68e942..575323a5dd64 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_management_group_diagnostic_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_management_group_diagnostic_settings_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -35,6 +36,10 @@ build_list_request, ) +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -85,8 +90,10 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementGroupDiagnosticSettingsResource] + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[_models.ManagementGroupDiagnosticSettingsResource] = kwargs.pop("cls", None) request = build_get_request( management_group_id=management_group_id, @@ -97,9 +104,9 @@ async def get( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -117,7 +124,9 @@ async def get( return deserialized - get.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore + get.metadata = { + "url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings/{name}" + } @overload async def create_or_update( @@ -190,8 +199,8 @@ async def create_or_update( :type management_group_id: str :param name: The name of the diagnostic setting. Required. :type name: str - :param parameters: Parameters supplied to the operation. Is either a model type or a IO type. - Required. + :param parameters: Parameters supplied to the operation. Is either a + ManagementGroupDiagnosticSettingsResource type or a IO type. Required. :type parameters: ~$(python-base-namespace).v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResource or IO @@ -215,9 +224,11 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementGroupDiagnosticSettingsResource] + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ManagementGroupDiagnosticSettingsResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -239,9 +250,9 @@ async def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -259,7 +270,9 @@ async def create_or_update( return deserialized - create_or_update.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore + create_or_update.metadata = { + "url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings/{name}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -287,8 +300,10 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( management_group_id=management_group_id, @@ -299,9 +314,9 @@ async def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -315,7 +330,9 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore + delete.metadata = { + "url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings/{name}" + } @distributed_trace def list( @@ -335,8 +352,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementGroupDiagnosticSettingsResourceCollection] + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[_models.ManagementGroupDiagnosticSettingsResourceCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -357,16 +376,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -374,13 +400,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ManagementGroupDiagnosticSettingsResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -394,4 +420,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings"} # type: ignore + list.metadata = { + "url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_predictive_metric_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_predictive_metric_operations.py index c0490e909645..1992631beb84 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_predictive_metric_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_predictive_metric_operations.py @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime +import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -28,6 +29,10 @@ from ..._vendor import _convert_request from ...operations._predictive_metric_operations import build_get_request +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -99,8 +104,10 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.PredictiveResponse] + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[_models.PredictiveResponse] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -117,9 +124,9 @@ async def get( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -137,4 +144,6 @@ async def get( return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}/predictiveMetrics"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}/predictiveMetrics" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_subscription_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_subscription_diagnostic_settings_operations.py index b96d8d491357..8b049792165c 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_subscription_diagnostic_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_subscription_diagnostic_settings_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -35,6 +36,10 @@ build_list_request, ) +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -81,8 +86,10 @@ async def get(self, name: str, **kwargs: Any) -> _models.SubscriptionDiagnosticS _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionDiagnosticSettingsResource] + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[_models.SubscriptionDiagnosticSettingsResource] = kwargs.pop("cls", None) request = build_get_request( name=name, @@ -93,9 +100,9 @@ async def get(self, name: str, **kwargs: Any) -> _models.SubscriptionDiagnosticS params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -113,7 +120,7 @@ async def get(self, name: str, **kwargs: Any) -> _models.SubscriptionDiagnosticS return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}"} @overload async def create_or_update( @@ -169,8 +176,8 @@ async def create_or_update( :param name: The name of the diagnostic setting. Required. :type name: str - :param parameters: Parameters supplied to the operation. Is either a model type or a IO type. - Required. + :param parameters: Parameters supplied to the operation. Is either a + SubscriptionDiagnosticSettingsResource type or a IO type. Required. :type parameters: ~$(python-base-namespace).v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResource or IO @@ -194,9 +201,11 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionDiagnosticSettingsResource] + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SubscriptionDiagnosticSettingsResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -218,9 +227,9 @@ async def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -238,7 +247,9 @@ async def create_or_update( return deserialized - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}" + } @distributed_trace_async async def delete(self, name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements @@ -262,8 +273,10 @@ async def delete(self, name: str, **kwargs: Any) -> None: # pylint: disable=inc _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( name=name, @@ -274,9 +287,9 @@ async def delete(self, name: str, **kwargs: Any) -> None: # pylint: disable=inc params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -290,7 +303,7 @@ async def delete(self, name: str, **kwargs: Any) -> None: # pylint: disable=inc if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}"} @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.SubscriptionDiagnosticSettingsResource"]: @@ -306,8 +319,10 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.SubscriptionDiagnosticSe _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionDiagnosticSettingsResourceCollection] + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[_models.SubscriptionDiagnosticSettingsResourceCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -328,16 +343,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -345,13 +367,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SubscriptionDiagnosticSettingsResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -365,4 +387,4 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/__init__.py index ddb1ad6b0547..aaaecfe7ecb4 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/__init__.py @@ -54,7 +54,7 @@ from ._monitor_management_client_enums import ScaleType from ._monitor_management_client_enums import TimeAggregationType from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/_models_py3.py index 5799ba559794..fce69f391cb6 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/_models_py3.py @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, TYPE_CHECKING, Union +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union from ... import _serialization @@ -38,7 +38,7 @@ class AutoscaleErrorResponse(_serialization.Model): "system_data": {"key": "systemData", "type": "SystemData"}, } - def __init__(self, *, error: Optional["_models.AutoscaleErrorResponseError"] = None, **kwargs): + def __init__(self, *, error: Optional["_models.AutoscaleErrorResponseError"] = None, **kwargs: Any) -> None: """ :keyword error: The error object. :paramtype error: @@ -76,8 +76,8 @@ def __init__( message: Optional[str] = None, target: Optional[str] = None, details: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword code: One of a server-defined set of error codes. :paramtype code: str @@ -129,8 +129,8 @@ def __init__( *, email: Optional["_models.EmailNotification"] = None, webhooks: Optional[List["_models.WebhookNotification"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword email: the email notification. :paramtype email: ~$(python-base-namespace).v2021_05_01_preview.models.EmailNotification @@ -185,8 +185,8 @@ def __init__( rules: List["_models.ScaleRule"], fixed_date: Optional["_models.TimeWindow"] = None, recurrence: Optional["_models.Recurrence"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: the name of the profile. Required. :paramtype name: str @@ -294,8 +294,8 @@ def __init__( name_properties_name: Optional[str] = None, target_resource_uri: Optional[str] = None, target_resource_location: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword location: Resource location. Required. :paramtype location: str @@ -363,7 +363,9 @@ class AutoscaleSettingResourceCollection(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, *, value: List["_models.AutoscaleSettingResource"], next_link: Optional[str] = None, **kwargs): + def __init__( + self, *, value: List["_models.AutoscaleSettingResource"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword value: the values for the autoscale setting resources. Required. :paramtype value: @@ -432,8 +434,8 @@ def __init__( name: Optional[str] = None, target_resource_uri: Optional[str] = None, target_resource_location: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword tags: Resource tags. :paramtype tags: dict[str, str] @@ -497,7 +499,7 @@ class Resource(_serialization.Model): "type": {"key": "type", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.id = None @@ -549,8 +551,8 @@ def __init__( *, category_type: Optional[Union[str, "_models.CategoryType"]] = None, category_groups: Optional[List[str]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword category_type: The type of the diagnostic settings category. Known values are: "Metrics" and "Logs". @@ -577,7 +579,9 @@ class DiagnosticSettingsCategoryResourceCollection(_serialization.Model): "value": {"key": "value", "type": "[DiagnosticSettingsCategoryResource]"}, } - def __init__(self, *, value: Optional[List["_models.DiagnosticSettingsCategoryResource"]] = None, **kwargs): + def __init__( + self, *, value: Optional[List["_models.DiagnosticSettingsCategoryResource"]] = None, **kwargs: Any + ) -> None: """ :keyword value: The collection of diagnostic settings category resources. :paramtype value: @@ -666,8 +670,8 @@ def __init__( workspace_id: Optional[str] = None, marketplace_partner_id: Optional[str] = None, log_analytics_destination_type: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword storage_account_id: The resource ID of the storage account to which you would like to send Diagnostic Logs. @@ -722,7 +726,7 @@ class DiagnosticSettingsResourceCollection(_serialization.Model): "value": {"key": "value", "type": "[DiagnosticSettingsResource]"}, } - def __init__(self, *, value: Optional[List["_models.DiagnosticSettingsResource"]] = None, **kwargs): + def __init__(self, *, value: Optional[List["_models.DiagnosticSettingsResource"]] = None, **kwargs: Any) -> None: """ :keyword value: The collection of diagnostic settings resources;. :paramtype value: @@ -758,8 +762,8 @@ def __init__( send_to_subscription_administrator: bool = False, send_to_subscription_co_administrators: bool = False, custom_emails: Optional[List[str]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword send_to_subscription_administrator: a value indicating whether to send email to subscription administrator. @@ -791,7 +795,7 @@ class ErrorResponse(_serialization.Model): "message": {"key": "message", "type": "str"}, } - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: """ :keyword code: Error code. :paramtype code: str @@ -840,8 +844,8 @@ def __init__( category: Optional[str] = None, category_group: Optional[str] = None, retention_policy: Optional["_models.RetentionPolicy"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword category: Name of a Diagnostic Log category for a resource type this setting is applied to. To obtain the list of Diagnostic Log categories for a resource, first perform a GET @@ -933,8 +937,8 @@ def __init__( logs: Optional[List["_models.ManagementGroupLogSettings"]] = None, workspace_id: Optional[str] = None, marketplace_partner_id: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword storage_account_id: The resource ID of the storage account to which you would like to send Diagnostic Logs. @@ -981,7 +985,9 @@ class ManagementGroupDiagnosticSettingsResourceCollection(_serialization.Model): "value": {"key": "value", "type": "[ManagementGroupDiagnosticSettingsResource]"}, } - def __init__(self, *, value: Optional[List["_models.ManagementGroupDiagnosticSettingsResource"]] = None, **kwargs): + def __init__( + self, *, value: Optional[List["_models.ManagementGroupDiagnosticSettingsResource"]] = None, **kwargs: Any + ) -> None: """ :keyword value: The collection of management group diagnostic settings resources. :paramtype value: @@ -1017,8 +1023,8 @@ class ManagementGroupLogSettings(_serialization.Model): } def __init__( - self, *, enabled: bool, category: Optional[str] = None, category_group: Optional[str] = None, **kwargs - ): + self, *, enabled: bool, category: Optional[str] = None, category_group: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword category: Name of a Management Group Diagnostic Log category for a resource type this setting is applied to. @@ -1070,8 +1076,8 @@ def __init__( time_grain: Optional[datetime.timedelta] = None, category: Optional[str] = None, retention_policy: Optional["_models.RetentionPolicy"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword time_grain: the timegrain of the metric in ISO8601 format. :paramtype time_grain: ~datetime.timedelta @@ -1178,8 +1184,8 @@ def __init__( metric_resource_location: Optional[str] = None, dimensions: Optional[List["_models.ScaleRuleMetricDimension"]] = None, divide_per_instance: Optional[bool] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword metric_name: the name of the metric that defines what the rule monitors. Required. :paramtype metric_name: str @@ -1264,8 +1270,8 @@ def __init__( *, scale_mode: Union[str, "_models.PredictiveAutoscalePolicyScaleMode"], scale_look_ahead_time: Optional[datetime.timedelta] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword scale_mode: the predictive autoscale mode. Required. Known values are: "Disabled", "ForecastOnly", and "Enabled". @@ -1315,8 +1321,8 @@ def __init__( metric_name: Optional[str] = None, target_resource_id: Optional[str] = None, data: Optional[List["_models.PredictiveValue"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword timespan: The timespan for which the data was retrieved. Its value consists of two datetimes concatenated, separated by '/'. This may be adjusted in the future and returned back @@ -1362,7 +1368,7 @@ class PredictiveValue(_serialization.Model): "value": {"key": "value", "type": "float"}, } - def __init__(self, *, time_stamp: datetime.datetime, value: float, **kwargs): + def __init__(self, *, time_stamp: datetime.datetime, value: float, **kwargs: Any) -> None: """ :keyword time_stamp: the timestamp for the metric value in ISO 8601 format. Required. :paramtype time_stamp: ~datetime.datetime @@ -1375,7 +1381,8 @@ def __init__(self, *, time_stamp: datetime.datetime, value: float, **kwargs): class Recurrence(_serialization.Model): - """The repeating times at which this profile begins. This element is not used if the FixedDate element is used. + """The repeating times at which this profile begins. This element is not used if the FixedDate + element is used. All required parameters must be populated in order to send to Azure. @@ -1401,8 +1408,12 @@ class Recurrence(_serialization.Model): } def __init__( - self, *, frequency: Union[str, "_models.RecurrenceFrequency"], schedule: "_models.RecurrentSchedule", **kwargs - ): + self, + *, + frequency: Union[str, "_models.RecurrenceFrequency"], + schedule: "_models.RecurrentSchedule", + **kwargs: Any + ) -> None: """ :keyword frequency: the recurrence frequency. How often the schedule profile should take effect. This value must be Week, meaning each week will have the same set of profiles. For @@ -1479,7 +1490,7 @@ class RecurrentSchedule(_serialization.Model): "minutes": {"key": "minutes", "type": "[int]"}, } - def __init__(self, *, time_zone: str, days: List[str], hours: List[int], minutes: List[int], **kwargs): + def __init__(self, *, time_zone: str, days: List[str], hours: List[int], minutes: List[int], **kwargs: Any) -> None: """ :keyword time_zone: the timezone for the hours of the profile. Some examples of valid time zones are: Dateline Standard Time, UTC-11, Hawaiian Standard Time, Alaskan Standard Time, @@ -1550,7 +1561,7 @@ class RetentionPolicy(_serialization.Model): "days": {"key": "days", "type": "int"}, } - def __init__(self, *, enabled: bool, days: int, **kwargs): + def __init__(self, *, enabled: bool, days: int, **kwargs: Any) -> None: """ :keyword enabled: a value indicating whether the retention policy is enabled. Required. :paramtype enabled: bool @@ -1602,8 +1613,8 @@ def __init__( type: Union[str, "_models.ScaleType"], cooldown: datetime.timedelta, value: str = "1", - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword direction: the scale direction. Whether the scaling action increases or decreases the number of instances. Required. Known values are: "None", "Increase", and "Decrease". @@ -1654,7 +1665,7 @@ class ScaleCapacity(_serialization.Model): "default": {"key": "default", "type": "str"}, } - def __init__(self, *, minimum: str, maximum: str, default: str, **kwargs): + def __init__(self, *, minimum: str, maximum: str, default: str, **kwargs: Any) -> None: """ :keyword minimum: the minimum number of instances for the resource. Required. :paramtype minimum: str @@ -1693,7 +1704,9 @@ class ScaleRule(_serialization.Model): "scale_action": {"key": "scaleAction", "type": "ScaleAction"}, } - def __init__(self, *, metric_trigger: "_models.MetricTrigger", scale_action: "_models.ScaleAction", **kwargs): + def __init__( + self, *, metric_trigger: "_models.MetricTrigger", scale_action: "_models.ScaleAction", **kwargs: Any + ) -> None: """ :keyword metric_trigger: the trigger that results in a scaling action. Required. :paramtype metric_trigger: ~$(python-base-namespace).v2021_05_01_preview.models.MetricTrigger @@ -1739,8 +1752,8 @@ def __init__( dimension_name: str, operator: Union[str, "_models.ScaleRuleMetricDimensionOperationType"], values: List[str], - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword dimension_name: Name of the dimension. Required. :paramtype dimension_name: str @@ -1827,8 +1840,8 @@ def __init__( logs: Optional[List["_models.SubscriptionLogSettings"]] = None, workspace_id: Optional[str] = None, marketplace_partner_id: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword storage_account_id: The resource ID of the storage account to which you would like to send Diagnostic Logs. @@ -1875,7 +1888,9 @@ class SubscriptionDiagnosticSettingsResourceCollection(_serialization.Model): "value": {"key": "value", "type": "[SubscriptionDiagnosticSettingsResource]"}, } - def __init__(self, *, value: Optional[List["_models.SubscriptionDiagnosticSettingsResource"]] = None, **kwargs): + def __init__( + self, *, value: Optional[List["_models.SubscriptionDiagnosticSettingsResource"]] = None, **kwargs: Any + ) -> None: """ :keyword value: The collection of subscription diagnostic settings resources. :paramtype value: @@ -1911,8 +1926,8 @@ class SubscriptionLogSettings(_serialization.Model): } def __init__( - self, *, enabled: bool, category: Optional[str] = None, category_group: Optional[str] = None, **kwargs - ): + self, *, enabled: bool, category: Optional[str] = None, category_group: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword category: Name of a Subscription Diagnostic Log category for a resource type this setting is applied to. @@ -1968,8 +1983,8 @@ def __init__( last_modified_by: Optional[str] = None, last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword created_by: The identity that created the resource. :paramtype created_by: str @@ -2050,7 +2065,9 @@ class TimeWindow(_serialization.Model): "end": {"key": "end", "type": "iso-8601"}, } - def __init__(self, *, start: datetime.datetime, end: datetime.datetime, time_zone: Optional[str] = None, **kwargs): + def __init__( + self, *, start: datetime.datetime, end: datetime.datetime, time_zone: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword time_zone: the timezone of the start and end times for the profile. Some examples of valid time zones are: Dateline Standard Time, UTC-11, Hawaiian Standard Time, Alaskan Standard @@ -2108,7 +2125,9 @@ class WebhookNotification(_serialization.Model): "properties": {"key": "properties", "type": "{str}"}, } - def __init__(self, *, service_uri: Optional[str] = None, properties: Optional[Dict[str, str]] = None, **kwargs): + def __init__( + self, *, service_uri: Optional[str] = None, properties: Optional[Dict[str, str]] = None, **kwargs: Any + ) -> None: """ :keyword service_uri: the service address to receive the notification. :paramtype service_uri: str diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/__init__.py index 8ada5606afee..526d8450f6ce 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/__init__.py @@ -14,7 +14,7 @@ from ._subscription_diagnostic_settings_operations import SubscriptionDiagnosticSettingsOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_autoscale_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_autoscale_settings_operations.py index 47e13b0093d0..b294a95f4112 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_autoscale_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_autoscale_settings_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,9 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -55,7 +62,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -72,8 +79,10 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -89,7 +98,7 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -108,7 +117,9 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -124,7 +135,7 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -141,7 +152,9 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -157,7 +170,7 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -174,8 +187,10 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -191,7 +206,7 @@ def build_update_request( "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -208,7 +223,9 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -217,7 +234,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -266,8 +283,10 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.AutoscaleSettingResourceCollection] + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[_models.AutoscaleSettingResourceCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -289,16 +308,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -306,13 +332,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("AutoscaleSettingResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -326,7 +352,9 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings" + } @overload def create_or_update( @@ -399,8 +427,8 @@ def create_or_update( :type resource_group_name: str :param autoscale_setting_name: The autoscale setting name. Required. :type autoscale_setting_name: str - :param parameters: Parameters supplied to the operation. Is either a model type or a IO type. - Required. + :param parameters: Parameters supplied to the operation. Is either a AutoscaleSettingResource + type or a IO type. Required. :type parameters: ~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -422,9 +450,11 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.AutoscaleSettingResource] + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AutoscaleSettingResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -447,9 +477,9 @@ def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -467,11 +497,13 @@ def create_or_update( deserialized = self._deserialize("AutoscaleSettingResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -500,8 +532,10 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -513,9 +547,9 @@ def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -529,7 +563,9 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}" + } @distributed_trace def get( @@ -558,8 +594,10 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.AutoscaleSettingResource] + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[_models.AutoscaleSettingResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -571,9 +609,9 @@ def get( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -591,7 +629,9 @@ def get( return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}" + } @overload def update( @@ -668,8 +708,8 @@ def update( :type resource_group_name: str :param autoscale_setting_name: The autoscale setting name. Required. :type autoscale_setting_name: str - :param autoscale_setting_resource: Parameters supplied to the operation. Is either a model type - or a IO type. Required. + :param autoscale_setting_resource: Parameters supplied to the operation. Is either a + AutoscaleSettingResourcePatch type or a IO type. Required. :type autoscale_setting_resource: ~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResourcePatch or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -691,9 +731,11 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.AutoscaleSettingResource] + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AutoscaleSettingResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -716,9 +758,9 @@ def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -736,7 +778,9 @@ def update( return deserialized - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}" + } @distributed_trace def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.AutoscaleSettingResource"]: @@ -752,8 +796,10 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.AutoscaleSett _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.AutoscaleSettingResourceCollection] + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[_models.AutoscaleSettingResourceCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -774,16 +820,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -791,13 +844,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("AutoscaleSettingResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -811,4 +864,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/autoscalesettings"} # type: ignore + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/autoscalesettings" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_diagnostic_settings_category_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_diagnostic_settings_category_operations.py index 4d87e72e75b8..d3a50d6b3dc3 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_diagnostic_settings_category_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_diagnostic_settings_category_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,9 @@ def build_get_request(resource_uri: str, name: str, **kwargs: Any) -> HttpReques _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -50,7 +57,7 @@ def build_get_request(resource_uri: str, name: str, **kwargs: Any) -> HttpReques "name": _SERIALIZER.url("name", name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -65,7 +72,9 @@ 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 = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -74,7 +83,7 @@ def build_list_request(resource_uri: str, **kwargs: Any) -> HttpRequest: "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -128,8 +137,10 @@ def get(self, resource_uri: str, name: str, **kwargs: Any) -> _models.Diagnostic _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticSettingsCategoryResource] + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[_models.DiagnosticSettingsCategoryResource] = kwargs.pop("cls", None) request = build_get_request( resource_uri=resource_uri, @@ -140,9 +151,9 @@ def get(self, resource_uri: str, name: str, **kwargs: Any) -> _models.Diagnostic params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -160,7 +171,7 @@ def get(self, resource_uri: str, name: str, **kwargs: Any) -> _models.Diagnostic return deserialized - get.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories/{name}"} # type: ignore + get.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories/{name}"} @distributed_trace def list(self, resource_uri: str, **kwargs: Any) -> Iterable["_models.DiagnosticSettingsCategoryResource"]: @@ -178,8 +189,10 @@ def list(self, resource_uri: str, **kwargs: Any) -> Iterable["_models.Diagnostic _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticSettingsCategoryResourceCollection] + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[_models.DiagnosticSettingsCategoryResourceCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -200,16 +213,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -217,13 +237,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("DiagnosticSettingsCategoryResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -237,4 +257,4 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories"} # type: ignore + list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_diagnostic_settings_operations.py index cae0b991050d..576be89e8045 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_diagnostic_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_diagnostic_settings_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,9 @@ def build_get_request(resource_uri: str, name: str, **kwargs: Any) -> HttpReques _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -50,7 +57,7 @@ def build_get_request(resource_uri: str, name: str, **kwargs: Any) -> HttpReques "name": _SERIALIZER.url("name", name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -65,8 +72,10 @@ def build_create_or_update_request(resource_uri: str, name: str, **kwargs: Any) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -76,7 +85,7 @@ def build_create_or_update_request(resource_uri: str, name: str, **kwargs: Any) "name": _SERIALIZER.url("name", name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -93,7 +102,9 @@ def build_delete_request(resource_uri: str, name: str, **kwargs: Any) -> HttpReq _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -103,7 +114,7 @@ def build_delete_request(resource_uri: str, name: str, **kwargs: Any) -> HttpReq "name": _SERIALIZER.url("name", name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -118,7 +129,9 @@ 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 = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -127,7 +140,7 @@ def build_list_request(resource_uri: str, **kwargs: Any) -> HttpRequest: "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -181,8 +194,10 @@ def get(self, resource_uri: str, name: str, **kwargs: Any) -> _models.Diagnostic _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticSettingsResource] + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[_models.DiagnosticSettingsResource] = kwargs.pop("cls", None) request = build_get_request( resource_uri=resource_uri, @@ -193,9 +208,9 @@ def get(self, resource_uri: str, name: str, **kwargs: Any) -> _models.Diagnostic params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -213,7 +228,7 @@ def get(self, resource_uri: str, name: str, **kwargs: Any) -> _models.Diagnostic return deserialized - get.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore + get.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} @overload def create_or_update( @@ -274,8 +289,8 @@ def create_or_update( :type resource_uri: str :param name: The name of the diagnostic setting. Required. :type name: str - :param parameters: Parameters supplied to the operation. Is either a model type or a IO type. - Required. + :param parameters: Parameters supplied to the operation. Is either a DiagnosticSettingsResource + type or a IO type. Required. :type parameters: ~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -297,9 +312,11 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticSettingsResource] + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DiagnosticSettingsResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -321,9 +338,9 @@ def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -341,7 +358,7 @@ def create_or_update( return deserialized - create_or_update.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore + create_or_update.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -369,8 +386,10 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_uri=resource_uri, @@ -381,9 +400,9 @@ def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -397,7 +416,7 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore + delete.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}"} @distributed_trace def list(self, resource_uri: str, **kwargs: Any) -> Iterable["_models.DiagnosticSettingsResource"]: @@ -415,8 +434,10 @@ def list(self, resource_uri: str, **kwargs: Any) -> Iterable["_models.Diagnostic _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticSettingsResourceCollection] + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[_models.DiagnosticSettingsResourceCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -437,16 +458,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -454,13 +482,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("DiagnosticSettingsResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -474,4 +502,4 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings"} # type: ignore + list.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_management_group_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_management_group_diagnostic_settings_operations.py index 2808534c4745..8b85cdc21d4c 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_management_group_diagnostic_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_management_group_diagnostic_settings_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,9 @@ def build_get_request(management_group_id: str, name: str, **kwargs: Any) -> Htt _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -53,7 +60,7 @@ def build_get_request(management_group_id: str, name: str, **kwargs: Any) -> Htt "name": _SERIALIZER.url("name", name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -68,8 +75,10 @@ def build_create_or_update_request(management_group_id: str, name: str, **kwargs _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -82,7 +91,7 @@ def build_create_or_update_request(management_group_id: str, name: str, **kwargs "name": _SERIALIZER.url("name", name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -99,7 +108,9 @@ def build_delete_request(management_group_id: str, name: str, **kwargs: Any) -> _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -112,7 +123,7 @@ def build_delete_request(management_group_id: str, name: str, **kwargs: Any) -> "name": _SERIALIZER.url("name", name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -127,7 +138,9 @@ def build_list_request(management_group_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -139,7 +152,7 @@ def build_list_request(management_group_id: str, **kwargs: Any) -> HttpRequest: "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, "str", skip_quote=True), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -196,8 +209,10 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementGroupDiagnosticSettingsResource] + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[_models.ManagementGroupDiagnosticSettingsResource] = kwargs.pop("cls", None) request = build_get_request( management_group_id=management_group_id, @@ -208,9 +223,9 @@ def get( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -228,7 +243,9 @@ def get( return deserialized - get.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore + get.metadata = { + "url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings/{name}" + } @overload def create_or_update( @@ -301,8 +318,8 @@ def create_or_update( :type management_group_id: str :param name: The name of the diagnostic setting. Required. :type name: str - :param parameters: Parameters supplied to the operation. Is either a model type or a IO type. - Required. + :param parameters: Parameters supplied to the operation. Is either a + ManagementGroupDiagnosticSettingsResource type or a IO type. Required. :type parameters: ~$(python-base-namespace).v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResource or IO @@ -326,9 +343,11 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementGroupDiagnosticSettingsResource] + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ManagementGroupDiagnosticSettingsResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -350,9 +369,9 @@ def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -370,7 +389,9 @@ def create_or_update( return deserialized - create_or_update.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore + create_or_update.metadata = { + "url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings/{name}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -398,8 +419,10 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( management_group_id=management_group_id, @@ -410,9 +433,9 @@ def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -426,7 +449,9 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore + delete.metadata = { + "url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings/{name}" + } @distributed_trace def list( @@ -446,8 +471,10 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementGroupDiagnosticSettingsResourceCollection] + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[_models.ManagementGroupDiagnosticSettingsResourceCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -468,16 +495,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -485,13 +519,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ManagementGroupDiagnosticSettingsResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -505,4 +539,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings"} # type: ignore + list.metadata = { + "url": "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_predictive_metric_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_predictive_metric_operations.py index eaf13eb4a106..1f43e8bcd21e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_predictive_metric_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_predictive_metric_operations.py @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime +import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -28,6 +29,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,7 +55,9 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -66,7 +73,7 @@ def build_get_request( "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["timespan"] = _SERIALIZER.query("timespan", timespan, "str") @@ -149,8 +156,10 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.PredictiveResponse] + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[_models.PredictiveResponse] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -167,9 +176,9 @@ def get( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -187,4 +196,6 @@ def get( return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}/predictiveMetrics"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}/predictiveMetrics" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_subscription_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_subscription_diagnostic_settings_operations.py index fe730767496f..b18d2953d6d1 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_subscription_diagnostic_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_subscription_diagnostic_settings_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,9 @@ def build_get_request(name: str, subscription_id: str, **kwargs: Any) -> HttpReq _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -52,7 +59,7 @@ def build_get_request(name: str, subscription_id: str, **kwargs: Any) -> HttpReq "name": _SERIALIZER.url("name", name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -67,8 +74,10 @@ def build_create_or_update_request(name: str, subscription_id: str, **kwargs: An _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -80,7 +89,7 @@ def build_create_or_update_request(name: str, subscription_id: str, **kwargs: An "name": _SERIALIZER.url("name", name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -97,7 +106,9 @@ def build_delete_request(name: str, subscription_id: str, **kwargs: Any) -> Http _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -109,7 +120,7 @@ def build_delete_request(name: str, subscription_id: str, **kwargs: Any) -> Http "name": _SERIALIZER.url("name", name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -124,7 +135,9 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -133,7 +146,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -186,8 +199,10 @@ def get(self, name: str, **kwargs: Any) -> _models.SubscriptionDiagnosticSetting _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionDiagnosticSettingsResource] + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[_models.SubscriptionDiagnosticSettingsResource] = kwargs.pop("cls", None) request = build_get_request( name=name, @@ -198,9 +213,9 @@ def get(self, name: str, **kwargs: Any) -> _models.SubscriptionDiagnosticSetting params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -218,7 +233,7 @@ def get(self, name: str, **kwargs: Any) -> _models.SubscriptionDiagnosticSetting return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}"} @overload def create_or_update( @@ -274,8 +289,8 @@ def create_or_update( :param name: The name of the diagnostic setting. Required. :type name: str - :param parameters: Parameters supplied to the operation. Is either a model type or a IO type. - Required. + :param parameters: Parameters supplied to the operation. Is either a + SubscriptionDiagnosticSettingsResource type or a IO type. Required. :type parameters: ~$(python-base-namespace).v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResource or IO @@ -299,9 +314,11 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionDiagnosticSettingsResource] + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SubscriptionDiagnosticSettingsResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -323,9 +340,9 @@ def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -343,7 +360,9 @@ def create_or_update( return deserialized - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}" + } @distributed_trace def delete(self, name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements @@ -367,8 +386,10 @@ def delete(self, name: str, **kwargs: Any) -> None: # pylint: disable=inconsist _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( name=name, @@ -379,9 +400,9 @@ def delete(self, name: str, **kwargs: Any) -> None: # pylint: disable=inconsist params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -395,7 +416,7 @@ def delete(self, name: str, **kwargs: Any) -> None: # pylint: disable=inconsist if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}"} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}"} @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.SubscriptionDiagnosticSettingsResource"]: @@ -411,8 +432,10 @@ def list(self, **kwargs: Any) -> Iterable["_models.SubscriptionDiagnosticSetting _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.SubscriptionDiagnosticSettingsResourceCollection] + api_version: Literal["2021-05-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) + cls: ClsType[_models.SubscriptionDiagnosticSettingsResourceCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -433,16 +456,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -450,13 +480,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SubscriptionDiagnosticSettingsResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -470,4 +500,4 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings"} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/__init__.py index 8ba4823444a9..2c7733bfd566 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/__init__.py @@ -13,12 +13,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["MonitorManagementClient"] +__all__ = [ + "MonitorManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_configuration.py index d9747582015e..7a6d3c839c73 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -36,7 +42,7 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2021-09-01") # type: str + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", "2021-09-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -50,10 +56,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, **kwargs # type: Any - ): - # type: (...) -> None + def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_metadata.json index 3248b516ad8c..58ac7be972a9 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_metadata.json @@ -19,13 +19,15 @@ "signature": "credential: \"TokenCredential\",", "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true + "required": true, + "method_location": "positional" }, "subscription_id": { "signature": "subscription_id: str,", "description": "The ID of the target subscription. Required.", "docstring_type": "str", - "required": true + "required": true, + "method_location": "positional" } }, "async": { @@ -48,22 +50,25 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "signature": "api_version: Optional[str]=None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } }, "async": { @@ -71,19 +76,22 @@ "signature": "api_version: Optional[str] = None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { "signature": "profile: KnownProfiles = KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } } } @@ -99,4 +107,4 @@ "operation_groups": { "action_groups": "ActionGroupsOperations" } -} \ No newline at end of file +} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_monitor_management_client.py index d118b8665881..9e79d3f59abd 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_monitor_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from . import models +from . import models as _models from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ActionGroupsOperations @@ -52,7 +52,7 @@ def __init__( ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -80,15 +80,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> MonitorManagementClient + def __enter__(self) -> "MonitorManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_vendor.py index 9aad73fc743e..bd0df84f5319 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_vendor.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_vendor.py @@ -5,6 +5,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import List, cast + from azure.core.pipeline.transport import HttpRequest @@ -22,6 +24,7 @@ def _format_url_section(template, **kwargs): try: return template.format(**kwargs) except KeyError as key: - formatted_components = template.split("/") + # Need the cast, as for some reasons "split" is typed as list[str | Any] + formatted_components = cast(List[str], template.split("/")) components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_version.py index ce9ac7ae37b3..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/__init__.py index 8638dc69d869..2c151bb41c19 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/__init__.py @@ -10,12 +10,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["MonitorManagementClient"] +__all__ = [ + "MonitorManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/_configuration.py index 408b4a00a20e..0416c819bcb8 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -36,7 +42,7 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2021-09-01") # type: str + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", "2021-09-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/_monitor_management_client.py index 8de8f7ade1f6..267bf81bbe07 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/_monitor_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from .. import models +from .. import models as _models from ..._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ActionGroupsOperations @@ -53,7 +53,7 @@ def __init__( ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -88,5 +88,5 @@ async def __aenter__(self) -> "MonitorManagementClient": await self._client.__aenter__() return self - async def __aexit__(self, *exc_details) -> None: + async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/operations/__init__.py index 0e396f5d7fb0..05f0527dc979 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/operations/__init__.py @@ -9,7 +9,7 @@ from ._action_groups_operations import ActionGroupsOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/operations/_action_groups_operations.py index 14ef831793ab..88a031ccb60f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/operations/_action_groups_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/operations/_action_groups_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -46,6 +47,10 @@ build_update_request, ) +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -140,8 +145,8 @@ async def create_or_update( :type resource_group_name: str :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group: The action group to create or use for the update. Is either a model type - or a IO type. Required. + :param action_group: The action group to create or use for the update. Is either a + ActionGroupResource type or a IO type. Required. :type action_group: ~$(python-base-namespace).v2021_09_01.models.ActionGroupResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -162,9 +167,9 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -187,9 +192,9 @@ async def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -207,11 +212,13 @@ async def create_or_update( deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}" + } @distributed_trace_async async def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) -> _models.ActionGroupResource: @@ -238,8 +245,8 @@ async def get(self, resource_group_name: str, action_group_name: str, **kwargs: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -251,9 +258,9 @@ async def get(self, resource_group_name: str, action_group_name: str, **kwargs: params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -271,7 +278,9 @@ async def get(self, resource_group_name: str, action_group_name: str, **kwargs: return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -300,8 +309,8 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -313,9 +322,9 @@ async def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -329,7 +338,9 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}" + } @overload async def update( @@ -402,8 +413,8 @@ async def update( :type resource_group_name: str :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Is either a model type or a IO - type. Required. + :param action_group_patch: Parameters supplied to the operation. Is either a + ActionGroupPatchBody type or a IO type. Required. :type action_group_patch: ~$(python-base-namespace).v2021_09_01.models.ActionGroupPatchBody or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -425,9 +436,9 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -450,9 +461,9 @@ async def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -470,7 +481,9 @@ async def update( return deserialized - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}" + } async def _post_test_notifications_initial( self, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any @@ -486,9 +499,9 @@ async def _post_test_notifications_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.TestNotificationDetailsResponse]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -509,9 +522,9 @@ async def _post_test_notifications_initial( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -535,7 +548,9 @@ async def _post_test_notifications_initial( return deserialized - _post_test_notifications_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications"} # type: ignore + _post_test_notifications_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications" + } @overload async def begin_post_test_notifications( @@ -603,7 +618,7 @@ async def begin_post_test_notifications( """Send test notifications to a set of provided receivers. :param notification_request: The notification request body which includes the contact details. - Is either a model type or a IO type. Required. + Is either a NotificationRequestBody type or a IO type. Required. :type notification_request: ~$(python-base-namespace).v2021_09_01.models.NotificationRequestBody or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -626,14 +641,14 @@ async def begin_post_test_notifications( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._post_test_notifications_initial( # type: ignore + raw_result = await self._post_test_notifications_initial( notification_request=notification_request, api_version=api_version, content_type=content_type, @@ -651,9 +666,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method = cast( + polling_method: AsyncPollingMethod = cast( AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) # type: AsyncPollingMethod + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: @@ -665,9 +680,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_post_test_notifications.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications"} # type: ignore + begin_post_test_notifications.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications" + } async def _create_notifications_at_resource_group_level_initial( self, resource_group_name: str, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any @@ -683,9 +700,9 @@ async def _create_notifications_at_resource_group_level_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.TestNotificationDetailsResponse]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -707,9 +724,9 @@ async def _create_notifications_at_resource_group_level_initial( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -733,7 +750,9 @@ async def _create_notifications_at_resource_group_level_initial( return deserialized - _create_notifications_at_resource_group_level_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications"} # type: ignore + _create_notifications_at_resource_group_level_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications" + } @overload async def begin_create_notifications_at_resource_group_level( @@ -816,7 +835,7 @@ async def begin_create_notifications_at_resource_group_level( Required. :type resource_group_name: str :param notification_request: The notification request body which includes the contact details. - Is either a model type or a IO type. Required. + Is either a NotificationRequestBody type or a IO type. Required. :type notification_request: ~$(python-base-namespace).v2021_09_01.models.NotificationRequestBody or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -839,14 +858,14 @@ async def begin_create_notifications_at_resource_group_level( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._create_notifications_at_resource_group_level_initial( # type: ignore + raw_result = await self._create_notifications_at_resource_group_level_initial( resource_group_name=resource_group_name, notification_request=notification_request, api_version=api_version, @@ -865,9 +884,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method = cast( + polling_method: AsyncPollingMethod = cast( AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) # type: AsyncPollingMethod + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: @@ -879,9 +898,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_notifications_at_resource_group_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications"} # type: ignore + begin_create_notifications_at_resource_group_level.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications" + } async def _create_notifications_at_action_group_resource_level_initial( self, @@ -901,9 +922,9 @@ async def _create_notifications_at_action_group_resource_level_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.TestNotificationDetailsResponse]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -926,9 +947,9 @@ async def _create_notifications_at_action_group_resource_level_initial( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -952,7 +973,9 @@ async def _create_notifications_at_action_group_resource_level_initial( return deserialized - _create_notifications_at_action_group_resource_level_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications"} # type: ignore + _create_notifications_at_action_group_resource_level_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications" + } @overload async def begin_create_notifications_at_action_group_resource_level( @@ -1047,7 +1070,7 @@ async def begin_create_notifications_at_action_group_resource_level( :param action_group_name: The name of the action group. Required. :type action_group_name: str :param notification_request: The notification request body which includes the contact details. - Is either a model type or a IO type. Required. + Is either a NotificationRequestBody type or a IO type. Required. :type notification_request: ~$(python-base-namespace).v2021_09_01.models.NotificationRequestBody or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -1070,14 +1093,14 @@ async def begin_create_notifications_at_action_group_resource_level( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._create_notifications_at_action_group_resource_level_initial( # type: ignore + raw_result = await self._create_notifications_at_action_group_resource_level_initial( resource_group_name=resource_group_name, action_group_name=action_group_name, notification_request=notification_request, @@ -1097,9 +1120,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method = cast( + polling_method: AsyncPollingMethod = cast( AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) # type: AsyncPollingMethod + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: @@ -1111,9 +1134,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_notifications_at_action_group_resource_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications"} # type: ignore + begin_create_notifications_at_action_group_resource_level.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications" + } @distributed_trace_async async def get_test_notifications( @@ -1139,8 +1164,8 @@ async def get_test_notifications( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) request = build_get_test_notifications_request( notification_id=notification_id, @@ -1151,9 +1176,9 @@ async def get_test_notifications( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -1171,7 +1196,9 @@ async def get_test_notifications( return deserialized - get_test_notifications.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/notificationStatus/{notificationId}"} # type: ignore + get_test_notifications.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/notificationStatus/{notificationId}" + } @distributed_trace_async async def get_test_notifications_at_resource_group_level( @@ -1200,8 +1227,8 @@ async def get_test_notifications_at_resource_group_level( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) request = build_get_test_notifications_at_resource_group_level_request( resource_group_name=resource_group_name, @@ -1213,9 +1240,9 @@ async def get_test_notifications_at_resource_group_level( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -1233,7 +1260,9 @@ async def get_test_notifications_at_resource_group_level( return deserialized - get_test_notifications_at_resource_group_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/notificationStatus/{notificationId}"} # type: ignore + get_test_notifications_at_resource_group_level.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/notificationStatus/{notificationId}" + } @distributed_trace_async async def get_test_notifications_at_action_group_resource_level( @@ -1264,8 +1293,8 @@ async def get_test_notifications_at_action_group_resource_level( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) request = build_get_test_notifications_at_action_group_resource_level_request( resource_group_name=resource_group_name, @@ -1278,9 +1307,9 @@ async def get_test_notifications_at_action_group_resource_level( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -1298,7 +1327,9 @@ async def get_test_notifications_at_action_group_resource_level( return deserialized - get_test_notifications_at_action_group_resource_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/notificationStatus/{notificationId}"} # type: ignore + get_test_notifications_at_action_group_resource_level.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/notificationStatus/{notificationId}" + } @distributed_trace def list_by_subscription_id(self, **kwargs: Any) -> AsyncIterable["_models.ActionGroupResource"]: @@ -1313,8 +1344,8 @@ def list_by_subscription_id(self, **kwargs: Any) -> AsyncIterable["_models.Actio _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -1335,16 +1366,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -1352,13 +1390,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ActionGroupList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1372,7 +1410,9 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_subscription_id.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/actionGroups"} # type: ignore + list_by_subscription_id.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/actionGroups" + } @distributed_trace def list_by_resource_group( @@ -1392,8 +1432,8 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -1415,16 +1455,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -1432,13 +1479,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ActionGroupList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1452,7 +1499,9 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups" + } @overload async def enable_receiver( # pylint: disable=inconsistent-return-statements @@ -1528,7 +1577,7 @@ async def enable_receiver( # pylint: disable=inconsistent-return-statements :type resource_group_name: str :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param enable_request: The receiver to re-enable. Is either a model type or a IO type. + :param enable_request: The receiver to re-enable. Is either a EnableRequest type or a IO type. Required. :type enable_request: ~$(python-base-namespace).v2021_09_01.models.EnableRequest or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -1550,9 +1599,9 @@ async def enable_receiver( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1575,9 +1624,9 @@ async def enable_receiver( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -1591,4 +1640,6 @@ async def enable_receiver( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - enable_receiver.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe"} # type: ignore + enable_receiver.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/models/__init__.py index c2c49e9b3b64..b1dac637c403 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/models/__init__.py @@ -30,7 +30,7 @@ from ._monitor_management_client_enums import ReceiverStatus from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/models/_models_py3.py index f416a68d80d5..8efe0a3b6148 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/models/_models_py3.py @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Dict, List, Optional, TYPE_CHECKING +from typing import Any, Dict, List, Optional, TYPE_CHECKING from ... import _serialization @@ -51,8 +51,8 @@ def __init__( sub_state: Optional[str] = None, send_time: Optional[str] = None, detail: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword mechanism_type: The mechanism type. :paramtype mechanism_type: str @@ -91,8 +91,12 @@ class ActionGroupList(_serialization.Model): } def __init__( - self, *, value: Optional[List["_models.ActionGroupResource"]] = None, next_link: Optional[str] = None, **kwargs - ): + self, + *, + value: Optional[List["_models.ActionGroupResource"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: """ :keyword value: The list of action groups. :paramtype value: list[~$(python-base-namespace).v2021_09_01.models.ActionGroupResource] @@ -119,7 +123,7 @@ class ActionGroupPatchBody(_serialization.Model): "enabled": {"key": "properties.enabled", "type": "bool"}, } - def __init__(self, *, tags: Optional[Dict[str, str]] = None, enabled: bool = True, **kwargs): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, enabled: bool = True, **kwargs: Any) -> None: """ :keyword tags: Resource tags. :paramtype tags: dict[str, str] @@ -166,7 +170,7 @@ class AzureResource(_serialization.Model): "tags": {"key": "tags", "type": "{str}"}, } - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: """ :keyword location: Resource location. Required. :paramtype location: str @@ -286,8 +290,8 @@ def __init__( azure_function_receivers: Optional[List["_models.AzureFunctionReceiver"]] = None, arm_role_receivers: Optional[List["_models.ArmRoleReceiver"]] = None, event_hub_receivers: Optional[List["_models.EventHubReceiver"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword location: Resource location. Required. :paramtype location: str @@ -376,7 +380,7 @@ class ArmRoleReceiver(_serialization.Model): "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, } - def __init__(self, *, name: str, role_id: str, use_common_alert_schema: bool = False, **kwargs): + def __init__(self, *, name: str, role_id: str, use_common_alert_schema: bool = False, **kwargs: Any) -> None: """ :keyword name: The name of the arm role receiver. Names must be unique across all receivers within an action group. Required. @@ -441,8 +445,8 @@ def __init__( name: Optional[str] = None, service_uri: Optional[str] = None, use_common_alert_schema: bool = False, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword automation_account_id: The Azure automation account Id which holds this runbook and authenticate to Azure resource. Required. @@ -492,7 +496,7 @@ class AzureAppPushReceiver(_serialization.Model): "email_address": {"key": "emailAddress", "type": "str"}, } - def __init__(self, *, name: str, email_address: str, **kwargs): + def __init__(self, *, name: str, email_address: str, **kwargs: Any) -> None: """ :keyword name: The name of the Azure mobile app push receiver. Names must be unique across all receivers within an action group. Required. @@ -546,8 +550,8 @@ def __init__( function_name: str, http_trigger_url: str, use_common_alert_schema: bool = False, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: The name of the azure function receiver. Names must be unique across all receivers within an action group. Required. @@ -583,7 +587,9 @@ class Context(_serialization.Model): "context_type": {"key": "contextType", "type": "str"}, } - def __init__(self, *, notification_source: Optional[str] = None, context_type: Optional[str] = None, **kwargs): + def __init__( + self, *, notification_source: Optional[str] = None, context_type: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword notification_source: The source of the notification request. :paramtype notification_source: str @@ -627,7 +633,7 @@ class EmailReceiver(_serialization.Model): "status": {"key": "status", "type": "str"}, } - def __init__(self, *, name: str, email_address: str, use_common_alert_schema: bool = False, **kwargs): + def __init__(self, *, name: str, email_address: str, use_common_alert_schema: bool = False, **kwargs: Any) -> None: """ :keyword name: The name of the email receiver. Names must be unique across all receivers within an action group. Required. @@ -661,7 +667,7 @@ class EnableRequest(_serialization.Model): "receiver_name": {"key": "receiverName", "type": "str"}, } - def __init__(self, *, receiver_name: str, **kwargs): + def __init__(self, *, receiver_name: str, **kwargs: Any) -> None: """ :keyword receiver_name: The name of the receiver to resubscribe. Required. :paramtype receiver_name: str @@ -684,7 +690,7 @@ class ErrorResponse(_serialization.Model): "message": {"key": "message", "type": "str"}, } - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: """ :keyword code: Error code. :paramtype code: str @@ -741,8 +747,8 @@ def __init__( subscription_id: str, use_common_alert_schema: bool = False, tenant_id: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: The name of the Event hub receiver. Names must be unique across all receivers within an action group. Required. @@ -806,8 +812,8 @@ class ItsmReceiver(_serialization.Model): } def __init__( - self, *, name: str, workspace_id: str, connection_id: str, ticket_configuration: str, region: str, **kwargs - ): + self, *, name: str, workspace_id: str, connection_id: str, ticket_configuration: str, region: str, **kwargs: Any + ) -> None: """ :keyword name: The name of the Itsm receiver. Names must be unique across all receivers within an action group. Required. @@ -863,8 +869,8 @@ class LogicAppReceiver(_serialization.Model): } def __init__( - self, *, name: str, resource_id: str, callback_url: str, use_common_alert_schema: bool = False, **kwargs - ): + self, *, name: str, resource_id: str, callback_url: str, use_common_alert_schema: bool = False, **kwargs: Any + ) -> None: """ :keyword name: The name of the logic app receiver. Names must be unique across all receivers within an action group. Required. @@ -888,7 +894,10 @@ class NotificationRequestBody(_serialization.Model): # pylint: disable=too-many All required parameters must be populated in order to send to Azure. - :ivar alert_type: The name of the supported alert type. Required. + :ivar alert_type: The value of the supported alert type. Supported alert type values are: + servicehealth, metricstaticthreshold, metricsdynamicthreshold, logalertv2, smartalert, + webtestalert, logalertv1numresult, logalertv1metricmeasurement, resourcehealth, activitylog, + actualcostbudget, forecastedbudget. Required. :vartype alert_type: str :ivar email_receivers: The list of email receivers that are part of this action group. :vartype email_receivers: list[~$(python-base-namespace).v2021_09_01.models.EmailReceiver] @@ -957,10 +966,13 @@ def __init__( azure_function_receivers: Optional[List["_models.AzureFunctionReceiver"]] = None, arm_role_receivers: Optional[List["_models.ArmRoleReceiver"]] = None, event_hub_receivers: Optional[List["_models.EventHubReceiver"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ - :keyword alert_type: The name of the supported alert type. Required. + :keyword alert_type: The value of the supported alert type. Supported alert type values are: + servicehealth, metricstaticthreshold, metricsdynamicthreshold, logalertv2, smartalert, + webtestalert, logalertv1numresult, logalertv1metricmeasurement, resourcehealth, activitylog, + actualcostbudget, forecastedbudget. Required. :paramtype alert_type: str :keyword email_receivers: The list of email receivers that are part of this action group. :paramtype email_receivers: list[~$(python-base-namespace).v2021_09_01.models.EmailReceiver] @@ -1046,7 +1058,7 @@ class SmsReceiver(_serialization.Model): "status": {"key": "status", "type": "str"}, } - def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs): + def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs: Any) -> None: """ :keyword name: The name of the SMS receiver. Names must be unique across all receivers within an action group. Required. @@ -1100,8 +1112,8 @@ def __init__( completed_time: Optional[str] = None, created_time: Optional[str] = None, action_details: Optional[List["_models.ActionDetail"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword context: The context info. :paramtype context: ~$(python-base-namespace).v2021_09_01.models.Context @@ -1148,7 +1160,7 @@ class VoiceReceiver(_serialization.Model): "phone_number": {"key": "phoneNumber", "type": "str"}, } - def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs): + def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs: Any) -> None: """ :keyword name: The name of the voice receiver. Names must be unique across all receivers within an action group. Required. @@ -1211,8 +1223,8 @@ def __init__( object_id: Optional[str] = None, identifier_uri: Optional[str] = None, tenant_id: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: The name of the webhook receiver. Names must be unique across all receivers within an action group. Required. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/operations/__init__.py index 0e396f5d7fb0..05f0527dc979 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/operations/__init__.py @@ -9,7 +9,7 @@ from ._action_groups_operations import ActionGroupsOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/operations/_action_groups_operations.py index 7f6b8232ca54..9b3239126b5e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/operations/_action_groups_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/operations/_action_groups_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -31,6 +32,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -44,8 +49,8 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -61,7 +66,7 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -80,7 +85,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -96,7 +101,7 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -113,7 +118,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -129,7 +134,7 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -146,8 +151,8 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -163,7 +168,7 @@ def build_update_request( "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -180,8 +185,8 @@ def build_post_test_notifications_request(subscription_id: str, **kwargs: Any) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -192,7 +197,7 @@ def build_post_test_notifications_request(subscription_id: str, **kwargs: Any) - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -211,8 +216,8 @@ def build_create_notifications_at_resource_group_level_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -227,7 +232,7 @@ def build_create_notifications_at_resource_group_level_request( ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -246,8 +251,8 @@ def build_create_notifications_at_action_group_resource_level_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -263,7 +268,7 @@ def build_create_notifications_at_action_group_resource_level_request( "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -280,7 +285,7 @@ def build_get_test_notifications_request(notification_id: str, subscription_id: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -293,7 +298,7 @@ def build_get_test_notifications_request(notification_id: str, subscription_id: "notificationId": _SERIALIZER.url("notification_id", notification_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -310,7 +315,7 @@ def build_get_test_notifications_at_resource_group_level_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -326,7 +331,7 @@ def build_get_test_notifications_at_resource_group_level_request( "notificationId": _SERIALIZER.url("notification_id", notification_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -343,7 +348,7 @@ def build_get_test_notifications_at_action_group_resource_level_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -360,7 +365,7 @@ def build_get_test_notifications_at_action_group_resource_level_request( "notificationId": _SERIALIZER.url("notification_id", notification_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -375,7 +380,7 @@ def build_list_by_subscription_id_request(subscription_id: str, **kwargs: Any) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -384,7 +389,7 @@ def build_list_by_subscription_id_request(subscription_id: str, **kwargs: Any) - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -399,7 +404,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -414,7 +419,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -431,8 +436,8 @@ def build_enable_receiver_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -448,7 +453,7 @@ def build_enable_receiver_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -551,8 +556,8 @@ def create_or_update( :type resource_group_name: str :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group: The action group to create or use for the update. Is either a model type - or a IO type. Required. + :param action_group: The action group to create or use for the update. Is either a + ActionGroupResource type or a IO type. Required. :type action_group: ~$(python-base-namespace).v2021_09_01.models.ActionGroupResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -573,9 +578,9 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -598,9 +603,9 @@ def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -618,11 +623,13 @@ def create_or_update( deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}" + } @distributed_trace def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) -> _models.ActionGroupResource: @@ -649,8 +656,8 @@ def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) - _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -662,9 +669,9 @@ def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) - params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -682,7 +689,9 @@ def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) - return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -711,8 +720,8 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -724,9 +733,9 @@ def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -740,7 +749,9 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}" + } @overload def update( @@ -813,8 +824,8 @@ def update( :type resource_group_name: str :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Is either a model type or a IO - type. Required. + :param action_group_patch: Parameters supplied to the operation. Is either a + ActionGroupPatchBody type or a IO type. Required. :type action_group_patch: ~$(python-base-namespace).v2021_09_01.models.ActionGroupPatchBody or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -836,9 +847,9 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -861,9 +872,9 @@ def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -881,7 +892,9 @@ def update( return deserialized - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}" + } def _post_test_notifications_initial( self, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any @@ -897,9 +910,9 @@ def _post_test_notifications_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.TestNotificationDetailsResponse]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -920,9 +933,9 @@ def _post_test_notifications_initial( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -946,7 +959,9 @@ def _post_test_notifications_initial( return deserialized - _post_test_notifications_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications"} # type: ignore + _post_test_notifications_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications" + } @overload def begin_post_test_notifications( @@ -1014,7 +1029,7 @@ def begin_post_test_notifications( """Send test notifications to a set of provided receivers. :param notification_request: The notification request body which includes the contact details. - Is either a model type or a IO type. Required. + Is either a NotificationRequestBody type or a IO type. Required. :type notification_request: ~$(python-base-namespace).v2021_09_01.models.NotificationRequestBody or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -1037,14 +1052,14 @@ def begin_post_test_notifications( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._post_test_notifications_initial( # type: ignore + raw_result = self._post_test_notifications_initial( notification_request=notification_request, api_version=api_version, content_type=content_type, @@ -1062,9 +1077,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method = cast( + polling_method: PollingMethod = cast( PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) # type: PollingMethod + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: @@ -1076,9 +1091,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_post_test_notifications.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications"} # type: ignore + begin_post_test_notifications.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications" + } def _create_notifications_at_resource_group_level_initial( self, resource_group_name: str, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any @@ -1094,9 +1111,9 @@ def _create_notifications_at_resource_group_level_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.TestNotificationDetailsResponse]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1118,9 +1135,9 @@ def _create_notifications_at_resource_group_level_initial( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -1144,7 +1161,9 @@ def _create_notifications_at_resource_group_level_initial( return deserialized - _create_notifications_at_resource_group_level_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications"} # type: ignore + _create_notifications_at_resource_group_level_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications" + } @overload def begin_create_notifications_at_resource_group_level( @@ -1227,7 +1246,7 @@ def begin_create_notifications_at_resource_group_level( Required. :type resource_group_name: str :param notification_request: The notification request body which includes the contact details. - Is either a model type or a IO type. Required. + Is either a NotificationRequestBody type or a IO type. Required. :type notification_request: ~$(python-base-namespace).v2021_09_01.models.NotificationRequestBody or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -1250,14 +1269,14 @@ def begin_create_notifications_at_resource_group_level( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._create_notifications_at_resource_group_level_initial( # type: ignore + raw_result = self._create_notifications_at_resource_group_level_initial( resource_group_name=resource_group_name, notification_request=notification_request, api_version=api_version, @@ -1276,9 +1295,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method = cast( + polling_method: PollingMethod = cast( PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) # type: PollingMethod + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: @@ -1290,9 +1309,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_notifications_at_resource_group_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications"} # type: ignore + begin_create_notifications_at_resource_group_level.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications" + } def _create_notifications_at_action_group_resource_level_initial( self, @@ -1312,9 +1333,9 @@ def _create_notifications_at_action_group_resource_level_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.TestNotificationDetailsResponse]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1337,9 +1358,9 @@ def _create_notifications_at_action_group_resource_level_initial( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -1363,7 +1384,9 @@ def _create_notifications_at_action_group_resource_level_initial( return deserialized - _create_notifications_at_action_group_resource_level_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications"} # type: ignore + _create_notifications_at_action_group_resource_level_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications" + } @overload def begin_create_notifications_at_action_group_resource_level( @@ -1458,7 +1481,7 @@ def begin_create_notifications_at_action_group_resource_level( :param action_group_name: The name of the action group. Required. :type action_group_name: str :param notification_request: The notification request body which includes the contact details. - Is either a model type or a IO type. Required. + Is either a NotificationRequestBody type or a IO type. Required. :type notification_request: ~$(python-base-namespace).v2021_09_01.models.NotificationRequestBody or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -1481,14 +1504,14 @@ def begin_create_notifications_at_action_group_resource_level( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._create_notifications_at_action_group_resource_level_initial( # type: ignore + raw_result = self._create_notifications_at_action_group_resource_level_initial( resource_group_name=resource_group_name, action_group_name=action_group_name, notification_request=notification_request, @@ -1508,9 +1531,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method = cast( + polling_method: PollingMethod = cast( PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) # type: PollingMethod + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: @@ -1522,9 +1545,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_notifications_at_action_group_resource_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications"} # type: ignore + begin_create_notifications_at_action_group_resource_level.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications" + } @distributed_trace def get_test_notifications(self, notification_id: str, **kwargs: Any) -> _models.TestNotificationDetailsResponse: @@ -1548,8 +1573,8 @@ def get_test_notifications(self, notification_id: str, **kwargs: Any) -> _models _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) request = build_get_test_notifications_request( notification_id=notification_id, @@ -1560,9 +1585,9 @@ def get_test_notifications(self, notification_id: str, **kwargs: Any) -> _models params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -1580,7 +1605,9 @@ def get_test_notifications(self, notification_id: str, **kwargs: Any) -> _models return deserialized - get_test_notifications.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/notificationStatus/{notificationId}"} # type: ignore + get_test_notifications.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/notificationStatus/{notificationId}" + } @distributed_trace def get_test_notifications_at_resource_group_level( @@ -1609,8 +1636,8 @@ def get_test_notifications_at_resource_group_level( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) request = build_get_test_notifications_at_resource_group_level_request( resource_group_name=resource_group_name, @@ -1622,9 +1649,9 @@ def get_test_notifications_at_resource_group_level( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -1642,7 +1669,9 @@ def get_test_notifications_at_resource_group_level( return deserialized - get_test_notifications_at_resource_group_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/notificationStatus/{notificationId}"} # type: ignore + get_test_notifications_at_resource_group_level.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/notificationStatus/{notificationId}" + } @distributed_trace def get_test_notifications_at_action_group_resource_level( @@ -1673,8 +1702,8 @@ def get_test_notifications_at_action_group_resource_level( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) request = build_get_test_notifications_at_action_group_resource_level_request( resource_group_name=resource_group_name, @@ -1687,9 +1716,9 @@ def get_test_notifications_at_action_group_resource_level( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -1707,7 +1736,9 @@ def get_test_notifications_at_action_group_resource_level( return deserialized - get_test_notifications_at_action_group_resource_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/notificationStatus/{notificationId}"} # type: ignore + get_test_notifications_at_action_group_resource_level.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/notificationStatus/{notificationId}" + } @distributed_trace def list_by_subscription_id(self, **kwargs: Any) -> Iterable["_models.ActionGroupResource"]: @@ -1722,8 +1753,8 @@ def list_by_subscription_id(self, **kwargs: Any) -> Iterable["_models.ActionGrou _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -1744,16 +1775,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -1761,13 +1799,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ActionGroupList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1781,7 +1819,9 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_subscription_id.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/actionGroups"} # type: ignore + list_by_subscription_id.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/actionGroups" + } @distributed_trace def list_by_resource_group( @@ -1801,8 +1841,8 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -1824,16 +1864,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -1841,13 +1888,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ActionGroupList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1861,7 +1908,9 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups" + } @overload def enable_receiver( # pylint: disable=inconsistent-return-statements @@ -1937,7 +1986,7 @@ def enable_receiver( # pylint: disable=inconsistent-return-statements :type resource_group_name: str :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param enable_request: The receiver to re-enable. Is either a model type or a IO type. + :param enable_request: The receiver to re-enable. Is either a EnableRequest type or a IO type. Required. :type enable_request: ~$(python-base-namespace).v2021_09_01.models.EnableRequest or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -1959,9 +2008,9 @@ def enable_receiver( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2021-09-01"] = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1984,9 +2033,9 @@ def enable_receiver( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -2000,4 +2049,6 @@ def enable_receiver( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - enable_receiver.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe"} # type: ignore + enable_receiver.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/__init__.py index 8ba4823444a9..2c7733bfd566 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/__init__.py @@ -13,12 +13,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["MonitorManagementClient"] +__all__ = [ + "MonitorManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_configuration.py index 2f986d7d4cf2..6fd488c201a4 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -36,7 +42,7 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2021-09-01-preview") # type: str + api_version: Literal["2021-09-01-preview"] = kwargs.pop("api_version", "2021-09-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -50,10 +56,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, **kwargs # type: Any - ): - # type: (...) -> None + def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_metadata.json index c341aa76d894..dd5ef3887f24 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_metadata.json @@ -19,13 +19,15 @@ "signature": "credential: \"TokenCredential\",", "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true + "required": true, + "method_location": "positional" }, "subscription_id": { "signature": "subscription_id: str,", "description": "The ID of the target subscription. Required.", "docstring_type": "str", - "required": true + "required": true, + "method_location": "positional" } }, "async": { @@ -48,22 +50,25 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "signature": "api_version: Optional[str]=None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } }, "async": { @@ -71,19 +76,22 @@ "signature": "api_version: Optional[str] = None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { "signature": "profile: KnownProfiles = KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } } } @@ -101,4 +109,4 @@ "data_collection_rule_associations": "DataCollectionRuleAssociationsOperations", "data_collection_rules": "DataCollectionRulesOperations" } -} \ No newline at end of file +} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_monitor_management_client.py index fc88d269f4dc..5ef03851fe41 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_monitor_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from . import models +from . import models as _models from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ( @@ -61,7 +61,7 @@ def __init__( ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -97,15 +97,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> MonitorManagementClient + def __enter__(self) -> "MonitorManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_vendor.py index 9aad73fc743e..bd0df84f5319 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_vendor.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_vendor.py @@ -5,6 +5,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import List, cast + from azure.core.pipeline.transport import HttpRequest @@ -22,6 +24,7 @@ def _format_url_section(template, **kwargs): try: return template.format(**kwargs) except KeyError as key: - formatted_components = template.split("/") + # Need the cast, as for some reasons "split" is typed as list[str | Any] + formatted_components = cast(List[str], template.split("/")) components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_version.py index ce9ac7ae37b3..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/__init__.py index 8638dc69d869..2c151bb41c19 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/__init__.py @@ -10,12 +10,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["MonitorManagementClient"] +__all__ = [ + "MonitorManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/_configuration.py index 7fc853a5afcf..163d71414550 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -36,7 +42,7 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2021-09-01-preview") # type: str + api_version: Literal["2021-09-01-preview"] = kwargs.pop("api_version", "2021-09-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/_monitor_management_client.py index 66c5f63c37bc..1e009649cd87 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/_monitor_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from .. import models +from .. import models as _models from ..._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ( @@ -61,7 +61,7 @@ def __init__( ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -104,5 +104,5 @@ async def __aenter__(self) -> "MonitorManagementClient": await self._client.__aenter__() return self - async def __aexit__(self, *exc_details) -> None: + async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/operations/__init__.py index 9d11e549f9e4..842046dd09e5 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/operations/__init__.py @@ -11,7 +11,7 @@ from ._data_collection_rules_operations import DataCollectionRulesOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/operations/_data_collection_endpoints_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/operations/_data_collection_endpoints_operations.py index 51dccbcdccd3..51a0c02959b2 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/operations/_data_collection_endpoints_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/operations/_data_collection_endpoints_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -37,6 +38,10 @@ build_update_request, ) +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -81,8 +86,10 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionEndpointResourceListResult] + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + cls: ClsType[_models.DataCollectionEndpointResourceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -104,16 +111,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -121,13 +135,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("DataCollectionEndpointResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -141,7 +155,9 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints" + } @distributed_trace def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.DataCollectionEndpointResource"]: @@ -159,8 +175,10 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.DataColl _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionEndpointResourceListResult] + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + cls: ClsType[_models.DataCollectionEndpointResourceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -181,16 +199,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -198,13 +223,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("DataCollectionEndpointResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -218,7 +243,9 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionEndpoints"} # type: ignore + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionEndpoints" + } @distributed_trace_async async def get( @@ -250,8 +277,10 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionEndpointResource] + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + cls: ClsType[_models.DataCollectionEndpointResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -263,9 +292,9 @@ async def get( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -283,7 +312,9 @@ async def get( return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}" + } @overload async def create( @@ -365,7 +396,8 @@ async def create( :param data_collection_endpoint_name: The name of the data collection endpoint. The name is case insensitive. Required. :type data_collection_endpoint_name: str - :param body: The payload. Is either a model type or a IO type. Default value is None. + :param body: The payload. Is either a DataCollectionEndpointResource type or a IO type. Default + value is None. :type body: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionEndpointResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -387,9 +419,11 @@ async def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionEndpointResource] + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataCollectionEndpointResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -415,9 +449,9 @@ async def create( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -435,11 +469,13 @@ async def create( deserialized = self._deserialize("DataCollectionEndpointResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}"} # type: ignore + create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}" + } @overload async def update( @@ -521,7 +557,8 @@ async def update( :param data_collection_endpoint_name: The name of the data collection endpoint. The name is case insensitive. Required. :type data_collection_endpoint_name: str - :param body: The payload. Is either a model type or a IO type. Default value is None. + :param body: The payload. Is either a ResourceForUpdate type or a IO type. Default value is + None. :type body: ~$(python-base-namespace).v2022_02_01_preview.models.ResourceForUpdate or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -542,9 +579,11 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionEndpointResource] + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataCollectionEndpointResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -570,9 +609,9 @@ async def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -590,7 +629,9 @@ async def update( return deserialized - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -622,8 +663,10 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -635,9 +678,9 @@ async def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -651,4 +694,6 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/operations/_data_collection_rule_associations_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/operations/_data_collection_rule_associations_operations.py index d82742443d92..5ce74dab3aa6 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/operations/_data_collection_rule_associations_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/operations/_data_collection_rule_associations_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -37,6 +38,10 @@ build_list_by_rule_request, ) +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -80,8 +85,10 @@ def list_by_resource( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -102,16 +109,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -121,13 +135,13 @@ async def extract_data(pipeline_response): ) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -141,7 +155,7 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations"} # type: ignore + list_by_resource.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations"} @distributed_trace def list_by_rule( @@ -167,8 +181,10 @@ def list_by_rule( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -191,16 +207,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -210,13 +233,13 @@ async def extract_data(pipeline_response): ) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -230,7 +253,9 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_rule.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations"} # type: ignore + list_by_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations" + } @distributed_trace def list_by_data_collection_endpoint( @@ -256,8 +281,10 @@ def list_by_data_collection_endpoint( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -280,16 +307,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -299,13 +333,13 @@ async def extract_data(pipeline_response): ) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -319,7 +353,9 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_data_collection_endpoint.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}/associations"} # type: ignore + list_by_data_collection_endpoint.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}/associations" + } @distributed_trace_async async def get( @@ -350,8 +386,10 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] = kwargs.pop("cls", None) request = build_get_request( resource_uri=resource_uri, @@ -362,9 +400,9 @@ async def get( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -382,7 +420,9 @@ async def get( return deserialized - get.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore + get.metadata = { + "url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" + } @overload async def create( @@ -461,7 +501,8 @@ async def create( :type resource_uri: str :param association_name: The name of the association. The name is case insensitive. Required. :type association_name: str - :param body: The payload. Is either a model type or a IO type. Default value is None. + :param body: The payload. Is either a DataCollectionRuleAssociationProxyOnlyResource type or a + IO type. Default value is None. :type body: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource or IO @@ -485,9 +526,11 @@ async def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -512,9 +555,9 @@ async def create( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -532,11 +575,13 @@ async def create( deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore + create.metadata = { + "url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -566,8 +611,10 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_uri=resource_uri, @@ -578,9 +625,9 @@ async def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -594,4 +641,6 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore + delete.metadata = { + "url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/operations/_data_collection_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/operations/_data_collection_rules_operations.py index 7881913800ab..a8fe0f214731 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/operations/_data_collection_rules_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/aio/operations/_data_collection_rules_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -37,6 +38,10 @@ build_update_request, ) +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -81,8 +86,10 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResourceListResult] + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + cls: ClsType[_models.DataCollectionRuleResourceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -104,16 +111,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -121,13 +135,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("DataCollectionRuleResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -141,7 +155,9 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules" + } @distributed_trace def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.DataCollectionRuleResource"]: @@ -159,8 +175,10 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.DataColl _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResourceListResult] + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + cls: ClsType[_models.DataCollectionRuleResourceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -181,16 +199,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -198,13 +223,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("DataCollectionRuleResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -218,7 +243,9 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionRules"} # type: ignore + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionRules" + } @distributed_trace_async async def get( @@ -250,8 +277,10 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResource] + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + cls: ClsType[_models.DataCollectionRuleResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -263,9 +292,9 @@ async def get( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -283,7 +312,9 @@ async def get( return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" + } @overload async def create( @@ -365,7 +396,8 @@ async def create( :param data_collection_rule_name: The name of the data collection rule. The name is case insensitive. Required. :type data_collection_rule_name: str - :param body: The payload. Is either a model type or a IO type. Default value is None. + :param body: The payload. Is either a DataCollectionRuleResource type or a IO type. Default + value is None. :type body: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -387,9 +419,11 @@ async def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResource] + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataCollectionRuleResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -415,9 +449,9 @@ async def create( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -435,11 +469,13 @@ async def create( deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore + create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" + } @overload async def update( @@ -521,7 +557,8 @@ async def update( :param data_collection_rule_name: The name of the data collection rule. The name is case insensitive. Required. :type data_collection_rule_name: str - :param body: The payload. Is either a model type or a IO type. Default value is None. + :param body: The payload. Is either a ResourceForUpdate type or a IO type. Default value is + None. :type body: ~$(python-base-namespace).v2022_02_01_preview.models.ResourceForUpdate or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -542,9 +579,11 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResource] + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataCollectionRuleResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -570,9 +609,9 @@ async def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -590,7 +629,9 @@ async def update( return deserialized - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -622,8 +663,10 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -635,9 +678,9 @@ async def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -651,4 +694,6 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/models/__init__.py index 5290d69732bf..f75486391895 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/models/__init__.py @@ -74,7 +74,7 @@ from ._monitor_management_client_enums import KnownSyslogDataSourceStreams from ._monitor_management_client_enums import KnownWindowsEventLogDataSourceStreams from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/models/_models_py3.py index 2005a20b773e..03bd67d3ba44 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/models/_models_py3.py @@ -13,13 +13,14 @@ from ... import _serialization -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models if sys.version_info >= (3, 9): from collections.abc import MutableMapping else: from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object @@ -36,7 +37,7 @@ class AzureMonitorMetricsDestination(_serialization.Model): "name": {"key": "name", "type": "str"}, } - def __init__(self, *, name: Optional[str] = None, **kwargs): + def __init__(self, *, name: Optional[str] = None, **kwargs: Any) -> None: """ :keyword name: A friendly name for the destination. This name should be unique across all destinations (regardless of type) within the data @@ -68,8 +69,8 @@ def __init__( *, name: Optional[str] = None, type: Optional[Union[str, "_models.KnownColumnDefinitionType"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: The name of the column. :paramtype name: str @@ -100,7 +101,7 @@ class ConfigurationAccessEndpointSpec(_serialization.Model): "endpoint": {"key": "endpoint", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.endpoint = None @@ -152,8 +153,8 @@ def __init__( configuration_access: Optional["_models.DataCollectionEndpointConfigurationAccess"] = None, logs_ingestion: Optional["_models.DataCollectionEndpointLogsIngestion"] = None, network_acls: Optional["_models.DataCollectionEndpointNetworkAcls"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword description: Description of the data collection endpoint. :paramtype description: str @@ -196,7 +197,7 @@ class DataCollectionEndpointConfigurationAccess(ConfigurationAccessEndpointSpec) "endpoint": {"key": "endpoint", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) @@ -218,7 +219,7 @@ class LogsIngestionEndpointSpec(_serialization.Model): "endpoint": {"key": "endpoint", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.endpoint = None @@ -241,7 +242,7 @@ class DataCollectionEndpointLogsIngestion(LogsIngestionEndpointSpec): "endpoint": {"key": "endpoint", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) @@ -260,8 +261,11 @@ class NetworkRuleSet(_serialization.Model): } def __init__( - self, *, public_network_access: Optional[Union[str, "_models.KnownPublicNetworkAccessOptions"]] = None, **kwargs - ): + self, + *, + public_network_access: Optional[Union[str, "_models.KnownPublicNetworkAccessOptions"]] = None, + **kwargs: Any + ) -> None: """ :keyword public_network_access: The configuration to set whether network access from public internet to the endpoints are allowed. Known values are: "Enabled" and "Disabled". @@ -286,8 +290,11 @@ class DataCollectionEndpointNetworkAcls(NetworkRuleSet): } def __init__( - self, *, public_network_access: Optional[Union[str, "_models.KnownPublicNetworkAccessOptions"]] = None, **kwargs - ): + self, + *, + public_network_access: Optional[Union[str, "_models.KnownPublicNetworkAccessOptions"]] = None, + **kwargs: Any + ) -> None: """ :keyword public_network_access: The configuration to set whether network access from public internet to the endpoints are allowed. Known values are: "Enabled" and "Disabled". @@ -383,8 +390,8 @@ def __init__( configuration_access: Optional["_models.DataCollectionEndpointConfigurationAccess"] = None, logs_ingestion: Optional["_models.DataCollectionEndpointLogsIngestion"] = None, network_acls: Optional["_models.DataCollectionEndpointNetworkAcls"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword location: The geo-location where the resource lives. Required. :paramtype location: str @@ -447,8 +454,8 @@ class DataCollectionEndpointResourceListResult(_serialization.Model): } def __init__( - self, *, value: List["_models.DataCollectionEndpointResource"], next_link: Optional[str] = None, **kwargs - ): + self, *, value: List["_models.DataCollectionEndpointResource"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword value: A list of resources. Required. :paramtype value: @@ -507,8 +514,8 @@ def __init__( configuration_access: Optional["_models.DataCollectionEndpointConfigurationAccess"] = None, logs_ingestion: Optional["_models.DataCollectionEndpointLogsIngestion"] = None, network_acls: Optional["_models.DataCollectionEndpointNetworkAcls"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword description: Description of the data collection endpoint. :paramtype description: str @@ -574,8 +581,8 @@ def __init__( last_modified_by: Optional[str] = None, last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword created_by: The identity that created the resource. :paramtype created_by: str @@ -642,8 +649,8 @@ def __init__( last_modified_by: Optional[str] = None, last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword created_by: The identity that created the resource. :paramtype created_by: str @@ -734,8 +741,8 @@ def __init__( data_sources: Optional["_models.DataCollectionRuleDataSources"] = None, destinations: Optional["_models.DataCollectionRuleDestinations"] = None, data_flows: Optional[List["_models.DataFlow"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword description: Description of the data collection rule. :paramtype description: str @@ -809,8 +816,8 @@ def __init__( description: Optional[str] = None, data_collection_rule_id: Optional[str] = None, data_collection_endpoint_id: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword description: Description of the association. :paramtype description: str @@ -846,7 +853,7 @@ class Metadata(_serialization.Model): "provisioned_by": {"key": "provisionedBy", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.provisioned_by = None @@ -869,7 +876,7 @@ class DataCollectionRuleAssociationMetadata(Metadata): "provisioned_by": {"key": "provisionedBy", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) @@ -936,8 +943,8 @@ def __init__( description: Optional[str] = None, data_collection_rule_id: Optional[str] = None, data_collection_endpoint_id: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword description: Description of the association. :paramtype description: str @@ -987,8 +994,8 @@ def __init__( *, value: List["_models.DataCollectionRuleAssociationProxyOnlyResource"], next_link: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword value: A list of resources. Required. :paramtype value: @@ -1042,8 +1049,8 @@ def __init__( description: Optional[str] = None, data_collection_rule_id: Optional[str] = None, data_collection_endpoint_id: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword description: Description of the association. :paramtype description: str @@ -1101,8 +1108,8 @@ def __init__( last_modified_by: Optional[str] = None, last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword created_by: The identity that created the resource. :paramtype created_by: str @@ -1171,8 +1178,8 @@ def __init__( extensions: Optional[List["_models.ExtensionDataSource"]] = None, log_files: Optional[List["_models.LogFilesDataSource"]] = None, iis_logs: Optional[List["_models.IisLogsDataSource"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword performance_counters: The list of performance counter data source configurations. :paramtype performance_counters: @@ -1203,24 +1210,25 @@ def __init__( class DataCollectionRuleDataSources(DataSourcesSpec): """The specification of data sources. - This property is optional and can be omitted if the rule is meant to be used via direct calls to the provisioned endpoint. + This property is optional and can be omitted if the rule is meant to be used via direct calls + to the provisioned endpoint. - :ivar performance_counters: The list of performance counter data source configurations. - :vartype performance_counters: - list[~$(python-base-namespace).v2022_02_01_preview.models.PerfCounterDataSource] - :ivar windows_event_logs: The list of Windows Event Log data source configurations. - :vartype windows_event_logs: - list[~$(python-base-namespace).v2022_02_01_preview.models.WindowsEventLogDataSource] - :ivar syslog: The list of Syslog data source configurations. - :vartype syslog: list[~$(python-base-namespace).v2022_02_01_preview.models.SyslogDataSource] - :ivar extensions: The list of Azure VM extension data source configurations. - :vartype extensions: - list[~$(python-base-namespace).v2022_02_01_preview.models.ExtensionDataSource] - :ivar log_files: The list of Log files source configurations. - :vartype log_files: - list[~$(python-base-namespace).v2022_02_01_preview.models.LogFilesDataSource] - :ivar iis_logs: The list of IIS logs source configurations. - :vartype iis_logs: list[~$(python-base-namespace).v2022_02_01_preview.models.IisLogsDataSource] + :ivar performance_counters: The list of performance counter data source configurations. + :vartype performance_counters: + list[~$(python-base-namespace).v2022_02_01_preview.models.PerfCounterDataSource] + :ivar windows_event_logs: The list of Windows Event Log data source configurations. + :vartype windows_event_logs: + list[~$(python-base-namespace).v2022_02_01_preview.models.WindowsEventLogDataSource] + :ivar syslog: The list of Syslog data source configurations. + :vartype syslog: list[~$(python-base-namespace).v2022_02_01_preview.models.SyslogDataSource] + :ivar extensions: The list of Azure VM extension data source configurations. + :vartype extensions: + list[~$(python-base-namespace).v2022_02_01_preview.models.ExtensionDataSource] + :ivar log_files: The list of Log files source configurations. + :vartype log_files: + list[~$(python-base-namespace).v2022_02_01_preview.models.LogFilesDataSource] + :ivar iis_logs: The list of IIS logs source configurations. + :vartype iis_logs: list[~$(python-base-namespace).v2022_02_01_preview.models.IisLogsDataSource] """ _attribute_map = { @@ -1241,8 +1249,8 @@ def __init__( extensions: Optional[List["_models.ExtensionDataSource"]] = None, log_files: Optional[List["_models.LogFilesDataSource"]] = None, iis_logs: Optional[List["_models.IisLogsDataSource"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword performance_counters: The list of performance counter data source configurations. :paramtype performance_counters: @@ -1294,8 +1302,8 @@ def __init__( *, log_analytics: Optional[List["_models.LogAnalyticsDestination"]] = None, azure_monitor_metrics: Optional["_models.DestinationsSpecAzureMonitorMetrics"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword log_analytics: List of Log Analytics destinations. :paramtype log_analytics: @@ -1330,8 +1338,8 @@ def __init__( *, log_analytics: Optional[List["_models.LogAnalyticsDestination"]] = None, azure_monitor_metrics: Optional["_models.DestinationsSpecAzureMonitorMetrics"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword log_analytics: List of Log Analytics destinations. :paramtype log_analytics: @@ -1360,7 +1368,7 @@ class DataCollectionRuleMetadata(Metadata): "provisioned_by": {"key": "provisionedBy", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) @@ -1463,8 +1471,8 @@ def __init__( data_sources: Optional["_models.DataCollectionRuleDataSources"] = None, destinations: Optional["_models.DataCollectionRuleDestinations"] = None, data_flows: Optional[List["_models.DataFlow"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword location: The geo-location where the resource lives. Required. :paramtype location: str @@ -1533,7 +1541,9 @@ class DataCollectionRuleResourceListResult(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, *, value: List["_models.DataCollectionRuleResource"], next_link: Optional[str] = None, **kwargs): + def __init__( + self, *, value: List["_models.DataCollectionRuleResource"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword value: A list of resources. Required. :paramtype value: @@ -1607,8 +1617,8 @@ def __init__( data_sources: Optional["_models.DataCollectionRuleDataSources"] = None, destinations: Optional["_models.DataCollectionRuleDestinations"] = None, data_flows: Optional[List["_models.DataFlow"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword description: Description of the data collection rule. :paramtype description: str @@ -1679,8 +1689,8 @@ def __init__( last_modified_by: Optional[str] = None, last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword created_by: The identity that created the resource. :paramtype created_by: str @@ -1739,8 +1749,8 @@ def __init__( destinations: Optional[List[str]] = None, transform_kql: Optional[str] = None, output_stream: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword streams: List of streams for this data flow. :paramtype streams: list[str or @@ -1773,7 +1783,7 @@ class DestinationsSpecAzureMonitorMetrics(AzureMonitorMetricsDestination): "name": {"key": "name", "type": "str"}, } - def __init__(self, *, name: Optional[str] = None, **kwargs): + def __init__(self, *, name: Optional[str] = None, **kwargs: Any) -> None: """ :keyword name: A friendly name for the destination. This name should be unique across all destinations (regardless of type) within the data @@ -1804,7 +1814,7 @@ class ErrorAdditionalInfo(_serialization.Model): "info": {"key": "info", "type": "object"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.type = None @@ -1845,7 +1855,7 @@ class ErrorDetail(_serialization.Model): "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) self.code = None @@ -1856,7 +1866,8 @@ def __init__(self, **kwargs): class ErrorResponseCommonV2(_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.). + """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: ~$(python-base-namespace).v2022_02_01_preview.models.ErrorDetail @@ -1866,7 +1877,7 @@ class ErrorResponseCommonV2(_serialization.Model): "error": {"key": "error", "type": "ErrorDetail"}, } - def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs): + def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: """ :keyword error: The error object. :paramtype error: ~$(python-base-namespace).v2022_02_01_preview.models.ErrorDetail @@ -1876,27 +1887,28 @@ def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs): class ExtensionDataSource(_serialization.Model): - """Definition of which data will be collected from a separate VM extension that integrates with the Azure Monitor Agent. + """Definition of which data will be collected from a separate VM extension that integrates with + the Azure Monitor Agent. Collected from either Windows and Linux machines, depending on which extension is defined. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to Azure. - :ivar streams: List of streams that this data source will be sent to. - A stream indicates what schema will be used for this data and usually what table in Log - Analytics the data will be sent to. - :vartype streams: list[str or - ~$(python-base-namespace).v2022_02_01_preview.models.KnownExtensionDataSourceStreams] - :ivar extension_name: The name of the VM extension. Required. - :vartype extension_name: str - :ivar extension_settings: The extension settings. The format is specific for particular - extension. - :vartype extension_settings: JSON - :ivar input_data_sources: The list of data sources this extension needs data from. - :vartype input_data_sources: list[str] - :ivar name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :vartype name: str + :ivar streams: List of streams that this data source will be sent to. + A stream indicates what schema will be used for this data and usually what table in Log + Analytics the data will be sent to. + :vartype streams: list[str or + ~$(python-base-namespace).v2022_02_01_preview.models.KnownExtensionDataSourceStreams] + :ivar extension_name: The name of the VM extension. Required. + :vartype extension_name: str + :ivar extension_settings: The extension settings. The format is specific for particular + extension. + :vartype extension_settings: JSON + :ivar input_data_sources: The list of data sources this extension needs data from. + :vartype input_data_sources: list[str] + :ivar name: A friendly name for the data source. + This name should be unique across all data sources (regardless of type) within the data + collection rule. + :vartype name: str """ _validation = { @@ -1919,8 +1931,8 @@ def __init__( extension_settings: Optional[JSON] = None, input_data_sources: Optional[List[str]] = None, name: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword streams: List of streams that this data source will be sent to. A stream indicates what schema will be used for this data and usually what table in Log @@ -1973,8 +1985,13 @@ class IisLogsDataSource(_serialization.Model): } def __init__( - self, *, streams: List[str], log_directories: Optional[List[str]] = None, name: Optional[str] = None, **kwargs - ): + self, + *, + streams: List[str], + log_directories: Optional[List[str]] = None, + name: Optional[str] = None, + **kwargs: Any + ) -> None: """ :keyword streams: IIS streams. Required. :paramtype streams: list[str] @@ -2016,7 +2033,9 @@ class LogAnalyticsDestination(_serialization.Model): "name": {"key": "name", "type": "str"}, } - def __init__(self, *, workspace_resource_id: Optional[str] = None, name: Optional[str] = None, **kwargs): + def __init__( + self, *, workspace_resource_id: Optional[str] = None, name: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword workspace_resource_id: The resource ID of the Log Analytics workspace. :paramtype workspace_resource_id: str @@ -2075,8 +2094,8 @@ def __init__( format: Union[str, "_models.KnownLogFilesDataSourceFormat"], settings: Optional["_models.LogFilesDataSourceSettings"] = None, name: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword streams: List of streams that this data source will be sent to. A stream indicates what schema will be used for this data source. Required. @@ -2113,7 +2132,7 @@ class LogFileSettings(_serialization.Model): "text": {"key": "text", "type": "LogFileSettingsText"}, } - def __init__(self, *, text: Optional["_models.LogFileSettingsText"] = None, **kwargs): + def __init__(self, *, text: Optional["_models.LogFileSettingsText"] = None, **kwargs: Any) -> None: """ :keyword text: Text settings. :paramtype text: ~$(python-base-namespace).v2022_02_01_preview.models.LogFileSettingsText @@ -2133,7 +2152,7 @@ class LogFilesDataSourceSettings(LogFileSettings): "text": {"key": "text", "type": "LogFileSettingsText"}, } - def __init__(self, *, text: Optional["_models.LogFileSettingsText"] = None, **kwargs): + def __init__(self, *, text: Optional["_models.LogFileSettingsText"] = None, **kwargs: Any) -> None: """ :keyword text: Text settings. :paramtype text: ~$(python-base-namespace).v2022_02_01_preview.models.LogFileSettingsText @@ -2166,8 +2185,8 @@ def __init__( self, *, record_start_timestamp_format: Union[str, "_models.KnownLogFileTextSettingsRecordStartTimestampFormat"], - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword record_start_timestamp_format: One of the supported timestamp formats. Required. Known values are: "ISO 8601", "YYYY-MM-DD HH:MM:SS", "M/D/YYYY HH:MM:SS AM/PM", "Mon DD, YYYY @@ -2205,8 +2224,8 @@ def __init__( self, *, record_start_timestamp_format: Union[str, "_models.KnownLogFileTextSettingsRecordStartTimestampFormat"], - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword record_start_timestamp_format: One of the supported timestamp formats. Required. Known values are: "ISO 8601", "YYYY-MM-DD HH:MM:SS", "M/D/YYYY HH:MM:SS AM/PM", "Mon DD, YYYY @@ -2219,26 +2238,27 @@ def __init__( class PerfCounterDataSource(_serialization.Model): - """Definition of which performance counters will be collected and how they will be collected by this data collection rule. + """Definition of which performance counters will be collected and how they will be collected by + this data collection rule. Collected from both Windows and Linux machines where the counter is present. - :ivar streams: List of streams that this data source will be sent to. - A stream indicates what schema will be used for this data and usually what table in Log - Analytics the data will be sent to. - :vartype streams: list[str or - ~$(python-base-namespace).v2022_02_01_preview.models.KnownPerfCounterDataSourceStreams] - :ivar sampling_frequency_in_seconds: The number of seconds between consecutive counter - measurements (samples). - :vartype sampling_frequency_in_seconds: int - :ivar counter_specifiers: A list of specifier names of the performance counters you want to - collect. - Use a wildcard (*) to collect a counter for all instances. - To get a list of performance counters on Windows, run the command 'typeperf'. - :vartype counter_specifiers: list[str] - :ivar name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :vartype name: str + :ivar streams: List of streams that this data source will be sent to. + A stream indicates what schema will be used for this data and usually what table in Log + Analytics the data will be sent to. + :vartype streams: list[str or + ~$(python-base-namespace).v2022_02_01_preview.models.KnownPerfCounterDataSourceStreams] + :ivar sampling_frequency_in_seconds: The number of seconds between consecutive counter + measurements (samples). + :vartype sampling_frequency_in_seconds: int + :ivar counter_specifiers: A list of specifier names of the performance counters you want to + collect. + Use a wildcard (*) to collect a counter for all instances. + To get a list of performance counters on Windows, run the command 'typeperf'. + :vartype counter_specifiers: list[str] + :ivar name: A friendly name for the data source. + This name should be unique across all data sources (regardless of type) within the data + collection rule. + :vartype name: str """ _attribute_map = { @@ -2255,8 +2275,8 @@ def __init__( sampling_frequency_in_seconds: Optional[int] = None, counter_specifiers: Optional[List[str]] = None, name: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword streams: List of streams that this data source will be sent to. A stream indicates what schema will be used for this data and usually what table in Log @@ -2294,7 +2314,7 @@ class ResourceForUpdate(_serialization.Model): "tags": {"key": "tags", "type": "{str}"}, } - def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: """ :keyword tags: Resource tags. :paramtype tags: dict[str, str] @@ -2314,7 +2334,7 @@ class StreamDeclaration(_serialization.Model): "columns": {"key": "columns", "type": "[ColumnDefinition]"}, } - def __init__(self, *, columns: Optional[List["_models.ColumnDefinition"]] = None, **kwargs): + def __init__(self, *, columns: Optional[List["_models.ColumnDefinition"]] = None, **kwargs: Any) -> None: """ :keyword columns: List of columns used by data in this stream. :paramtype columns: list[~$(python-base-namespace).v2022_02_01_preview.models.ColumnDefinition] @@ -2327,21 +2347,21 @@ class SyslogDataSource(_serialization.Model): """Definition of which syslog data will be collected and how it will be collected. Only collected from Linux machines. - :ivar streams: List of streams that this data source will be sent to. - A stream indicates what schema will be used for this data and usually what table in Log - Analytics the data will be sent to. - :vartype streams: list[str or - ~$(python-base-namespace).v2022_02_01_preview.models.KnownSyslogDataSourceStreams] - :ivar facility_names: The list of facility names. - :vartype facility_names: list[str or - ~$(python-base-namespace).v2022_02_01_preview.models.KnownSyslogDataSourceFacilityNames] - :ivar log_levels: The log levels to collect. - :vartype log_levels: list[str or - ~$(python-base-namespace).v2022_02_01_preview.models.KnownSyslogDataSourceLogLevels] - :ivar name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :vartype name: str + :ivar streams: List of streams that this data source will be sent to. + A stream indicates what schema will be used for this data and usually what table in Log + Analytics the data will be sent to. + :vartype streams: list[str or + ~$(python-base-namespace).v2022_02_01_preview.models.KnownSyslogDataSourceStreams] + :ivar facility_names: The list of facility names. + :vartype facility_names: list[str or + ~$(python-base-namespace).v2022_02_01_preview.models.KnownSyslogDataSourceFacilityNames] + :ivar log_levels: The log levels to collect. + :vartype log_levels: list[str or + ~$(python-base-namespace).v2022_02_01_preview.models.KnownSyslogDataSourceLogLevels] + :ivar name: A friendly name for the data source. + This name should be unique across all data sources (regardless of type) within the data + collection rule. + :vartype name: str """ _attribute_map = { @@ -2358,8 +2378,8 @@ def __init__( facility_names: Optional[List[Union[str, "_models.KnownSyslogDataSourceFacilityNames"]]] = None, log_levels: Optional[List[Union[str, "_models.KnownSyslogDataSourceLogLevels"]]] = None, name: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword streams: List of streams that this data source will be sent to. A stream indicates what schema will be used for this data and usually what table in Log @@ -2388,17 +2408,17 @@ class WindowsEventLogDataSource(_serialization.Model): """Definition of which Windows Event Log events will be collected and how they will be collected. Only collected from Windows machines. - :ivar streams: List of streams that this data source will be sent to. - A stream indicates what schema will be used for this data and usually what table in Log - Analytics the data will be sent to. - :vartype streams: list[str or - ~$(python-base-namespace).v2022_02_01_preview.models.KnownWindowsEventLogDataSourceStreams] - :ivar x_path_queries: A list of Windows Event Log queries in XPATH format. - :vartype x_path_queries: list[str] - :ivar name: A friendly name for the data source. - This name should be unique across all data sources (regardless of type) within the data - collection rule. - :vartype name: str + :ivar streams: List of streams that this data source will be sent to. + A stream indicates what schema will be used for this data and usually what table in Log + Analytics the data will be sent to. + :vartype streams: list[str or + ~$(python-base-namespace).v2022_02_01_preview.models.KnownWindowsEventLogDataSourceStreams] + :ivar x_path_queries: A list of Windows Event Log queries in XPATH format. + :vartype x_path_queries: list[str] + :ivar name: A friendly name for the data source. + This name should be unique across all data sources (regardless of type) within the data + collection rule. + :vartype name: str """ _attribute_map = { @@ -2413,8 +2433,8 @@ def __init__( streams: Optional[List[Union[str, "_models.KnownWindowsEventLogDataSourceStreams"]]] = None, x_path_queries: Optional[List[str]] = None, name: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword streams: List of streams that this data source will be sent to. A stream indicates what schema will be used for this data and usually what table in Log diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/operations/__init__.py index 9d11e549f9e4..842046dd09e5 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/operations/__init__.py @@ -11,7 +11,7 @@ from ._data_collection_rules_operations import DataCollectionRulesOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/operations/_data_collection_endpoints_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/operations/_data_collection_endpoints_operations.py index dbfa14b8d003..e743b0ec40ab 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/operations/_data_collection_endpoints_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/operations/_data_collection_endpoints_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,9 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -55,7 +62,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -70,7 +77,9 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -81,7 +90,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -98,7 +107,9 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -116,7 +127,7 @@ def build_get_request( ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -133,8 +144,10 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -152,7 +165,7 @@ def build_create_request( ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -171,8 +184,10 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -190,7 +205,7 @@ def build_update_request( ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -209,7 +224,9 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -227,7 +244,7 @@ def build_delete_request( ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -278,8 +295,10 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionEndpointResourceListResult] + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + cls: ClsType[_models.DataCollectionEndpointResourceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -301,16 +320,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -318,13 +344,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("DataCollectionEndpointResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -338,7 +364,9 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints" + } @distributed_trace def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.DataCollectionEndpointResource"]: @@ -356,8 +384,10 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.DataCollectio _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionEndpointResourceListResult] + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + cls: ClsType[_models.DataCollectionEndpointResourceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -378,16 +408,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -395,13 +432,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("DataCollectionEndpointResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -415,7 +452,9 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionEndpoints"} # type: ignore + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionEndpoints" + } @distributed_trace def get( @@ -447,8 +486,10 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionEndpointResource] + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + cls: ClsType[_models.DataCollectionEndpointResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -460,9 +501,9 @@ def get( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -480,7 +521,9 @@ def get( return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}" + } @overload def create( @@ -562,7 +605,8 @@ def create( :param data_collection_endpoint_name: The name of the data collection endpoint. The name is case insensitive. Required. :type data_collection_endpoint_name: str - :param body: The payload. Is either a model type or a IO type. Default value is None. + :param body: The payload. Is either a DataCollectionEndpointResource type or a IO type. Default + value is None. :type body: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionEndpointResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -584,9 +628,11 @@ def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionEndpointResource] + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataCollectionEndpointResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -612,9 +658,9 @@ def create( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -632,11 +678,13 @@ def create( deserialized = self._deserialize("DataCollectionEndpointResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}"} # type: ignore + create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}" + } @overload def update( @@ -718,7 +766,8 @@ def update( :param data_collection_endpoint_name: The name of the data collection endpoint. The name is case insensitive. Required. :type data_collection_endpoint_name: str - :param body: The payload. Is either a model type or a IO type. Default value is None. + :param body: The payload. Is either a ResourceForUpdate type or a IO type. Default value is + None. :type body: ~$(python-base-namespace).v2022_02_01_preview.models.ResourceForUpdate or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -739,9 +788,11 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionEndpointResource] + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataCollectionEndpointResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -767,9 +818,9 @@ def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -787,7 +838,9 @@ def update( return deserialized - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -819,8 +872,10 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -832,9 +887,9 @@ def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -848,4 +903,6 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/operations/_data_collection_rule_associations_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/operations/_data_collection_rule_associations_operations.py index cd2335cb63a6..eb9c04c8a0d8 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/operations/_data_collection_rule_associations_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/operations/_data_collection_rule_associations_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,9 @@ def build_list_by_resource_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 = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -49,7 +56,7 @@ def build_list_by_resource_request(resource_uri: str, **kwargs: Any) -> HttpRequ "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, "str", skip_quote=True, min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -66,7 +73,9 @@ def build_list_by_rule_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -82,7 +91,7 @@ def build_list_by_rule_request( "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -99,7 +108,9 @@ def build_list_by_data_collection_endpoint_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -117,7 +128,7 @@ def build_list_by_data_collection_endpoint_request( ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -132,7 +143,9 @@ def build_get_request(resource_uri: str, association_name: str, **kwargs: Any) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -144,7 +157,7 @@ def build_get_request(resource_uri: str, association_name: str, **kwargs: Any) - "associationName": _SERIALIZER.url("association_name", association_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -159,8 +172,10 @@ def build_create_request(resource_uri: str, association_name: str, **kwargs: Any _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -172,7 +187,7 @@ def build_create_request(resource_uri: str, association_name: str, **kwargs: Any "associationName": _SERIALIZER.url("association_name", association_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -189,7 +204,9 @@ def build_delete_request(resource_uri: str, association_name: str, **kwargs: Any _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -201,7 +218,7 @@ def build_delete_request(resource_uri: str, association_name: str, **kwargs: Any "associationName": _SERIALIZER.url("association_name", association_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -251,8 +268,10 @@ def list_by_resource( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -273,16 +292,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -292,13 +318,13 @@ def extract_data(pipeline_response): ) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -312,7 +338,7 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations"} # type: ignore + list_by_resource.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations"} @distributed_trace def list_by_rule( @@ -338,8 +364,10 @@ def list_by_rule( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -362,16 +390,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -381,13 +416,13 @@ def extract_data(pipeline_response): ) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -401,7 +436,9 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_rule.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations"} # type: ignore + list_by_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations" + } @distributed_trace def list_by_data_collection_endpoint( @@ -427,8 +464,10 @@ def list_by_data_collection_endpoint( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResourceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -451,16 +490,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -470,13 +516,13 @@ def extract_data(pipeline_response): ) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -490,7 +536,9 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_data_collection_endpoint.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}/associations"} # type: ignore + list_by_data_collection_endpoint.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}/associations" + } @distributed_trace def get( @@ -521,8 +569,10 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] = kwargs.pop("cls", None) request = build_get_request( resource_uri=resource_uri, @@ -533,9 +583,9 @@ def get( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -553,7 +603,9 @@ def get( return deserialized - get.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore + get.metadata = { + "url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" + } @overload def create( @@ -632,7 +684,8 @@ def create( :type resource_uri: str :param association_name: The name of the association. The name is case insensitive. Required. :type association_name: str - :param body: The payload. Is either a model type or a IO type. Default value is None. + :param body: The payload. Is either a DataCollectionRuleAssociationProxyOnlyResource type or a + IO type. Default value is None. :type body: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource or IO @@ -656,9 +709,11 @@ def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataCollectionRuleAssociationProxyOnlyResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -683,9 +738,9 @@ def create( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -703,11 +758,13 @@ def create( deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore + create.metadata = { + "url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -737,8 +794,10 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_uri=resource_uri, @@ -749,9 +808,9 @@ def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -765,4 +824,6 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}"} # type: ignore + delete.metadata = { + "url": "/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/operations/_data_collection_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/operations/_data_collection_rules_operations.py index d06b9df9de74..752796754d3a 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/operations/_data_collection_rules_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_02_01_preview/operations/_data_collection_rules_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,9 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -55,7 +62,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -70,7 +77,9 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -81,7 +90,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -98,7 +107,9 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -114,7 +125,7 @@ def build_get_request( "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -131,8 +142,10 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -148,7 +161,7 @@ def build_create_request( "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -167,8 +180,10 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -184,7 +199,7 @@ def build_update_request( "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -203,7 +218,9 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -219,7 +236,7 @@ def build_delete_request( "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_rule_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -270,8 +287,10 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResourceListResult] + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + cls: ClsType[_models.DataCollectionRuleResourceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -293,16 +312,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -310,13 +336,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("DataCollectionRuleResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -330,7 +356,9 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules" + } @distributed_trace def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.DataCollectionRuleResource"]: @@ -348,8 +376,10 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.DataCollectio _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResourceListResult] + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + cls: ClsType[_models.DataCollectionRuleResourceListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -370,16 +400,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -387,13 +424,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("DataCollectionRuleResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -407,7 +444,9 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionRules"} # type: ignore + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionRules" + } @distributed_trace def get( @@ -439,8 +478,10 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResource] + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + cls: ClsType[_models.DataCollectionRuleResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -452,9 +493,9 @@ def get( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -472,7 +513,9 @@ def get( return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" + } @overload def create( @@ -554,7 +597,8 @@ def create( :param data_collection_rule_name: The name of the data collection rule. The name is case insensitive. Required. :type data_collection_rule_name: str - :param body: The payload. Is either a model type or a IO type. Default value is None. + :param body: The payload. Is either a DataCollectionRuleResource type or a IO type. Default + value is None. :type body: ~$(python-base-namespace).v2022_02_01_preview.models.DataCollectionRuleResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -576,9 +620,11 @@ def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResource] + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataCollectionRuleResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -604,9 +650,9 @@ def create( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -624,11 +670,13 @@ def create( deserialized = self._deserialize("DataCollectionRuleResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore + create.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" + } @overload def update( @@ -710,7 +758,8 @@ def update( :param data_collection_rule_name: The name of the data collection rule. The name is case insensitive. Required. :type data_collection_rule_name: str - :param body: The payload. Is either a model type or a IO type. Default value is None. + :param body: The payload. Is either a ResourceForUpdate type or a IO type. Default value is + None. :type body: ~$(python-base-namespace).v2022_02_01_preview.models.ResourceForUpdate or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -731,9 +780,11 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.DataCollectionRuleResource] + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DataCollectionRuleResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -759,9 +810,9 @@ def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -779,7 +830,9 @@ def update( return deserialized - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -811,8 +864,10 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01-preview")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2021-09-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2021-09-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -824,9 +879,9 @@ def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -840,4 +895,6 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/__init__.py index 8ba4823444a9..2c7733bfd566 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/__init__.py @@ -13,12 +13,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["MonitorManagementClient"] +__all__ = [ + "MonitorManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_configuration.py index 6510a97f9b50..b9ec9715dd48 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -36,7 +42,7 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2022-04-01") # type: str + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", "2022-04-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -50,10 +56,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, **kwargs # type: Any - ): - # type: (...) -> None + def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_metadata.json index 6e8a63a85edf..c8694bb8c160 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_metadata.json @@ -19,13 +19,15 @@ "signature": "credential: \"TokenCredential\",", "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true + "required": true, + "method_location": "positional" }, "subscription_id": { "signature": "subscription_id: str,", "description": "The ID of the target subscription. Required.", "docstring_type": "str", - "required": true + "required": true, + "method_location": "positional" } }, "async": { @@ -48,22 +50,25 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "signature": "api_version: Optional[str]=None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } }, "async": { @@ -71,19 +76,22 @@ "signature": "api_version: Optional[str] = None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { "signature": "profile: KnownProfiles = KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } } } @@ -99,4 +107,4 @@ "operation_groups": { "action_groups": "ActionGroupsOperations" } -} \ No newline at end of file +} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_monitor_management_client.py index 7caa7070567a..521badfbfd8f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_monitor_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from . import models +from . import models as _models from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ActionGroupsOperations @@ -52,7 +52,7 @@ def __init__( ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -80,15 +80,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> MonitorManagementClient + def __enter__(self) -> "MonitorManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_vendor.py index 9aad73fc743e..bd0df84f5319 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_vendor.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_vendor.py @@ -5,6 +5,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import List, cast + from azure.core.pipeline.transport import HttpRequest @@ -22,6 +24,7 @@ def _format_url_section(template, **kwargs): try: return template.format(**kwargs) except KeyError as key: - formatted_components = template.split("/") + # Need the cast, as for some reasons "split" is typed as list[str | Any] + formatted_components = cast(List[str], template.split("/")) components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_version.py index ce9ac7ae37b3..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/__init__.py index 8638dc69d869..2c151bb41c19 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/__init__.py @@ -10,12 +10,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["MonitorManagementClient"] +__all__ = [ + "MonitorManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/_configuration.py index 077f9e2dcc34..6905ba16088c 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -36,7 +42,7 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2022-04-01") # type: str + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", "2022-04-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/_monitor_management_client.py index 9c614f848585..6ac81e1699b0 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/_monitor_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from .. import models +from .. import models as _models from ..._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ActionGroupsOperations @@ -53,7 +53,7 @@ def __init__( ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -88,5 +88,5 @@ async def __aenter__(self) -> "MonitorManagementClient": await self._client.__aenter__() return self - async def __aexit__(self, *exc_details) -> None: + async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/operations/__init__.py index 0e396f5d7fb0..05f0527dc979 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/operations/__init__.py @@ -9,7 +9,7 @@ from ._action_groups_operations import ActionGroupsOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/operations/_action_groups_operations.py index 4326a9dc44d4..b04edb0cf527 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/operations/_action_groups_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/aio/operations/_action_groups_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -44,6 +45,10 @@ build_update_request, ) +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -138,8 +143,8 @@ async def create_or_update( :type resource_group_name: str :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group: The action group to create or use for the update. Is either a model type - or a IO type. Required. + :param action_group: The action group to create or use for the update. Is either a + ActionGroupResource type or a IO type. Required. :type action_group: ~$(python-base-namespace).v2022_04_01.models.ActionGroupResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -160,9 +165,9 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -185,9 +190,9 @@ async def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -205,11 +210,13 @@ async def create_or_update( deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}" + } @distributed_trace_async async def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) -> _models.ActionGroupResource: @@ -236,8 +243,8 @@ async def get(self, resource_group_name: str, action_group_name: str, **kwargs: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -249,9 +256,9 @@ async def get(self, resource_group_name: str, action_group_name: str, **kwargs: params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -269,7 +276,9 @@ async def get(self, resource_group_name: str, action_group_name: str, **kwargs: return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -298,8 +307,8 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -311,9 +320,9 @@ async def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -327,7 +336,9 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}" + } @overload async def update( @@ -400,8 +411,8 @@ async def update( :type resource_group_name: str :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Is either a model type or a IO - type. Required. + :param action_group_patch: Parameters supplied to the operation. Is either a + ActionGroupPatchBody type or a IO type. Required. :type action_group_patch: ~$(python-base-namespace).v2022_04_01.models.ActionGroupPatchBody or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -423,9 +434,9 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -448,9 +459,9 @@ async def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -468,7 +479,9 @@ async def update( return deserialized - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}" + } async def _post_test_notifications_initial( self, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any @@ -484,9 +497,9 @@ async def _post_test_notifications_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.TestNotificationDetailsResponse]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -507,9 +520,9 @@ async def _post_test_notifications_initial( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -533,7 +546,9 @@ async def _post_test_notifications_initial( return deserialized - _post_test_notifications_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications"} # type: ignore + _post_test_notifications_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications" + } @overload async def begin_post_test_notifications( @@ -601,7 +616,7 @@ async def begin_post_test_notifications( """Send test notifications to a set of provided receivers. :param notification_request: The notification request body which includes the contact details. - Is either a model type or a IO type. Required. + Is either a NotificationRequestBody type or a IO type. Required. :type notification_request: ~$(python-base-namespace).v2022_04_01.models.NotificationRequestBody or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -624,14 +639,14 @@ async def begin_post_test_notifications( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._post_test_notifications_initial( # type: ignore + raw_result = await self._post_test_notifications_initial( notification_request=notification_request, api_version=api_version, content_type=content_type, @@ -649,9 +664,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method = cast( + polling_method: AsyncPollingMethod = cast( AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) # type: AsyncPollingMethod + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: @@ -663,9 +678,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_post_test_notifications.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications"} # type: ignore + begin_post_test_notifications.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications" + } async def _create_notifications_at_resource_group_level_initial( self, resource_group_name: str, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any @@ -681,9 +698,9 @@ async def _create_notifications_at_resource_group_level_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.TestNotificationDetailsResponse]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -705,9 +722,9 @@ async def _create_notifications_at_resource_group_level_initial( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -731,7 +748,9 @@ async def _create_notifications_at_resource_group_level_initial( return deserialized - _create_notifications_at_resource_group_level_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications"} # type: ignore + _create_notifications_at_resource_group_level_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications" + } @overload async def begin_create_notifications_at_resource_group_level( @@ -814,7 +833,7 @@ async def begin_create_notifications_at_resource_group_level( Required. :type resource_group_name: str :param notification_request: The notification request body which includes the contact details. - Is either a model type or a IO type. Required. + Is either a NotificationRequestBody type or a IO type. Required. :type notification_request: ~$(python-base-namespace).v2022_04_01.models.NotificationRequestBody or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -837,14 +856,14 @@ async def begin_create_notifications_at_resource_group_level( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._create_notifications_at_resource_group_level_initial( # type: ignore + raw_result = await self._create_notifications_at_resource_group_level_initial( resource_group_name=resource_group_name, notification_request=notification_request, api_version=api_version, @@ -863,9 +882,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method = cast( + polling_method: AsyncPollingMethod = cast( AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) # type: AsyncPollingMethod + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: @@ -877,9 +896,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_notifications_at_resource_group_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications"} # type: ignore + begin_create_notifications_at_resource_group_level.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications" + } @distributed_trace_async async def get_test_notifications( @@ -905,8 +926,8 @@ async def get_test_notifications( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) request = build_get_test_notifications_request( notification_id=notification_id, @@ -917,9 +938,9 @@ async def get_test_notifications( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -937,7 +958,9 @@ async def get_test_notifications( return deserialized - get_test_notifications.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/notificationStatus/{notificationId}"} # type: ignore + get_test_notifications.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/notificationStatus/{notificationId}" + } @distributed_trace_async async def get_test_notifications_at_resource_group_level( @@ -966,8 +989,8 @@ async def get_test_notifications_at_resource_group_level( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) request = build_get_test_notifications_at_resource_group_level_request( resource_group_name=resource_group_name, @@ -979,9 +1002,9 @@ async def get_test_notifications_at_resource_group_level( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -999,7 +1022,9 @@ async def get_test_notifications_at_resource_group_level( return deserialized - get_test_notifications_at_resource_group_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/notificationStatus/{notificationId}"} # type: ignore + get_test_notifications_at_resource_group_level.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/notificationStatus/{notificationId}" + } @distributed_trace def list_by_subscription_id(self, **kwargs: Any) -> AsyncIterable["_models.ActionGroupResource"]: @@ -1014,8 +1039,8 @@ def list_by_subscription_id(self, **kwargs: Any) -> AsyncIterable["_models.Actio _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -1036,16 +1061,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -1053,13 +1085,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ActionGroupList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1073,7 +1105,9 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_subscription_id.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/actionGroups"} # type: ignore + list_by_subscription_id.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/actionGroups" + } @distributed_trace def list_by_resource_group( @@ -1093,8 +1127,8 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -1116,16 +1150,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -1133,13 +1174,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ActionGroupList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1153,7 +1194,9 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups" + } @overload async def enable_receiver( # pylint: disable=inconsistent-return-statements @@ -1229,7 +1272,7 @@ async def enable_receiver( # pylint: disable=inconsistent-return-statements :type resource_group_name: str :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param enable_request: The receiver to re-enable. Is either a model type or a IO type. + :param enable_request: The receiver to re-enable. Is either a EnableRequest type or a IO type. Required. :type enable_request: ~$(python-base-namespace).v2022_04_01.models.EnableRequest or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -1251,9 +1294,9 @@ async def enable_receiver( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1276,9 +1319,9 @@ async def enable_receiver( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -1292,4 +1335,6 @@ async def enable_receiver( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - enable_receiver.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe"} # type: ignore + enable_receiver.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/models/__init__.py index c2c49e9b3b64..b1dac637c403 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/models/__init__.py @@ -30,7 +30,7 @@ from ._monitor_management_client_enums import ReceiverStatus from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/models/_models_py3.py index 0445731b0312..0d9bc341310e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/models/_models_py3.py @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Dict, List, Optional, TYPE_CHECKING +from typing import Any, Dict, List, Optional, TYPE_CHECKING from ... import _serialization @@ -51,8 +51,8 @@ def __init__( sub_state: Optional[str] = None, send_time: Optional[str] = None, detail: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword mechanism_type: The mechanism type. :paramtype mechanism_type: str @@ -91,8 +91,12 @@ class ActionGroupList(_serialization.Model): } def __init__( - self, *, value: Optional[List["_models.ActionGroupResource"]] = None, next_link: Optional[str] = None, **kwargs - ): + self, + *, + value: Optional[List["_models.ActionGroupResource"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: """ :keyword value: The list of action groups. :paramtype value: list[~$(python-base-namespace).v2022_04_01.models.ActionGroupResource] @@ -119,7 +123,7 @@ class ActionGroupPatchBody(_serialization.Model): "enabled": {"key": "properties.enabled", "type": "bool"}, } - def __init__(self, *, tags: Optional[Dict[str, str]] = None, enabled: bool = True, **kwargs): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, enabled: bool = True, **kwargs: Any) -> None: """ :keyword tags: Resource tags. :paramtype tags: dict[str, str] @@ -166,7 +170,7 @@ class AzureResource(_serialization.Model): "tags": {"key": "tags", "type": "{str}"}, } - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: """ :keyword location: Resource location. Required. :paramtype location: str @@ -286,8 +290,8 @@ def __init__( azure_function_receivers: Optional[List["_models.AzureFunctionReceiver"]] = None, arm_role_receivers: Optional[List["_models.ArmRoleReceiver"]] = None, event_hub_receivers: Optional[List["_models.EventHubReceiver"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword location: Resource location. Required. :paramtype location: str @@ -376,7 +380,7 @@ class ArmRoleReceiver(_serialization.Model): "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, } - def __init__(self, *, name: str, role_id: str, use_common_alert_schema: bool = False, **kwargs): + def __init__(self, *, name: str, role_id: str, use_common_alert_schema: bool = False, **kwargs: Any) -> None: """ :keyword name: The name of the arm role receiver. Names must be unique across all receivers within an action group. Required. @@ -441,8 +445,8 @@ def __init__( name: Optional[str] = None, service_uri: Optional[str] = None, use_common_alert_schema: bool = False, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword automation_account_id: The Azure automation account Id which holds this runbook and authenticate to Azure resource. Required. @@ -492,7 +496,7 @@ class AzureAppPushReceiver(_serialization.Model): "email_address": {"key": "emailAddress", "type": "str"}, } - def __init__(self, *, name: str, email_address: str, **kwargs): + def __init__(self, *, name: str, email_address: str, **kwargs: Any) -> None: """ :keyword name: The name of the Azure mobile app push receiver. Names must be unique across all receivers within an action group. Required. @@ -546,8 +550,8 @@ def __init__( function_name: str, http_trigger_url: str, use_common_alert_schema: bool = False, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: The name of the azure function receiver. Names must be unique across all receivers within an action group. Required. @@ -583,7 +587,9 @@ class Context(_serialization.Model): "context_type": {"key": "contextType", "type": "str"}, } - def __init__(self, *, notification_source: Optional[str] = None, context_type: Optional[str] = None, **kwargs): + def __init__( + self, *, notification_source: Optional[str] = None, context_type: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword notification_source: The source of the notification request. :paramtype notification_source: str @@ -627,7 +633,7 @@ class EmailReceiver(_serialization.Model): "status": {"key": "status", "type": "str"}, } - def __init__(self, *, name: str, email_address: str, use_common_alert_schema: bool = False, **kwargs): + def __init__(self, *, name: str, email_address: str, use_common_alert_schema: bool = False, **kwargs: Any) -> None: """ :keyword name: The name of the email receiver. Names must be unique across all receivers within an action group. Required. @@ -661,7 +667,7 @@ class EnableRequest(_serialization.Model): "receiver_name": {"key": "receiverName", "type": "str"}, } - def __init__(self, *, receiver_name: str, **kwargs): + def __init__(self, *, receiver_name: str, **kwargs: Any) -> None: """ :keyword receiver_name: The name of the receiver to resubscribe. Required. :paramtype receiver_name: str @@ -684,7 +690,7 @@ class ErrorResponse(_serialization.Model): "message": {"key": "message", "type": "str"}, } - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: """ :keyword code: Error code. :paramtype code: str @@ -741,8 +747,8 @@ def __init__( subscription_id: str, use_common_alert_schema: bool = False, tenant_id: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: The name of the Event hub receiver. Names must be unique across all receivers within an action group. Required. @@ -806,8 +812,8 @@ class ItsmReceiver(_serialization.Model): } def __init__( - self, *, name: str, workspace_id: str, connection_id: str, ticket_configuration: str, region: str, **kwargs - ): + self, *, name: str, workspace_id: str, connection_id: str, ticket_configuration: str, region: str, **kwargs: Any + ) -> None: """ :keyword name: The name of the Itsm receiver. Names must be unique across all receivers within an action group. Required. @@ -863,8 +869,8 @@ class LogicAppReceiver(_serialization.Model): } def __init__( - self, *, name: str, resource_id: str, callback_url: str, use_common_alert_schema: bool = False, **kwargs - ): + self, *, name: str, resource_id: str, callback_url: str, use_common_alert_schema: bool = False, **kwargs: Any + ) -> None: """ :keyword name: The name of the logic app receiver. Names must be unique across all receivers within an action group. Required. @@ -888,7 +894,10 @@ class NotificationRequestBody(_serialization.Model): # pylint: disable=too-many All required parameters must be populated in order to send to Azure. - :ivar alert_type: The name of the supported alert type. Required. + :ivar alert_type: The value of the supported alert type. Supported alert type values are: + servicehealth, metricstaticthreshold, metricsdynamicthreshold, logalertv2, smartalert, + webtestalert, logalertv1numresult, logalertv1metricmeasurement, resourcehealth, activitylog, + actualcostbudget, forecastedbudget. Required. :vartype alert_type: str :ivar email_receivers: The list of email receivers that are part of this action group. :vartype email_receivers: list[~$(python-base-namespace).v2022_04_01.models.EmailReceiver] @@ -957,10 +966,13 @@ def __init__( azure_function_receivers: Optional[List["_models.AzureFunctionReceiver"]] = None, arm_role_receivers: Optional[List["_models.ArmRoleReceiver"]] = None, event_hub_receivers: Optional[List["_models.EventHubReceiver"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ - :keyword alert_type: The name of the supported alert type. Required. + :keyword alert_type: The value of the supported alert type. Supported alert type values are: + servicehealth, metricstaticthreshold, metricsdynamicthreshold, logalertv2, smartalert, + webtestalert, logalertv1numresult, logalertv1metricmeasurement, resourcehealth, activitylog, + actualcostbudget, forecastedbudget. Required. :paramtype alert_type: str :keyword email_receivers: The list of email receivers that are part of this action group. :paramtype email_receivers: list[~$(python-base-namespace).v2022_04_01.models.EmailReceiver] @@ -1046,7 +1058,7 @@ class SmsReceiver(_serialization.Model): "status": {"key": "status", "type": "str"}, } - def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs): + def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs: Any) -> None: """ :keyword name: The name of the SMS receiver. Names must be unique across all receivers within an action group. Required. @@ -1100,8 +1112,8 @@ def __init__( completed_time: Optional[str] = None, created_time: Optional[str] = None, action_details: Optional[List["_models.ActionDetail"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword context: The context info. :paramtype context: ~$(python-base-namespace).v2022_04_01.models.Context @@ -1148,7 +1160,7 @@ class VoiceReceiver(_serialization.Model): "phone_number": {"key": "phoneNumber", "type": "str"}, } - def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs): + def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs: Any) -> None: """ :keyword name: The name of the voice receiver. Names must be unique across all receivers within an action group. Required. @@ -1211,8 +1223,8 @@ def __init__( object_id: Optional[str] = None, identifier_uri: Optional[str] = None, tenant_id: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: The name of the webhook receiver. Names must be unique across all receivers within an action group. Required. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/operations/__init__.py index 0e396f5d7fb0..05f0527dc979 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/operations/__init__.py @@ -9,7 +9,7 @@ from ._action_groups_operations import ActionGroupsOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/operations/_action_groups_operations.py index 0472c5aa6152..8ed06eedb4e6 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/operations/_action_groups_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_04_01/operations/_action_groups_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -31,6 +32,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -44,8 +49,8 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -61,7 +66,7 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -80,7 +85,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -96,7 +101,7 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -113,7 +118,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -129,7 +134,7 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -146,8 +151,8 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -163,7 +168,7 @@ def build_update_request( "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -180,8 +185,8 @@ def build_post_test_notifications_request(subscription_id: str, **kwargs: Any) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -192,7 +197,7 @@ def build_post_test_notifications_request(subscription_id: str, **kwargs: Any) - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -211,8 +216,8 @@ def build_create_notifications_at_resource_group_level_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -227,7 +232,7 @@ def build_create_notifications_at_resource_group_level_request( ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -244,7 +249,7 @@ def build_get_test_notifications_request(notification_id: str, subscription_id: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -257,7 +262,7 @@ def build_get_test_notifications_request(notification_id: str, subscription_id: "notificationId": _SERIALIZER.url("notification_id", notification_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -274,7 +279,7 @@ def build_get_test_notifications_at_resource_group_level_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -290,7 +295,7 @@ def build_get_test_notifications_at_resource_group_level_request( "notificationId": _SERIALIZER.url("notification_id", notification_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -305,7 +310,7 @@ def build_list_by_subscription_id_request(subscription_id: str, **kwargs: Any) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -314,7 +319,7 @@ def build_list_by_subscription_id_request(subscription_id: str, **kwargs: Any) - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -329,7 +334,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -344,7 +349,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -361,8 +366,8 @@ def build_enable_receiver_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -378,7 +383,7 @@ def build_enable_receiver_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -481,8 +486,8 @@ def create_or_update( :type resource_group_name: str :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group: The action group to create or use for the update. Is either a model type - or a IO type. Required. + :param action_group: The action group to create or use for the update. Is either a + ActionGroupResource type or a IO type. Required. :type action_group: ~$(python-base-namespace).v2022_04_01.models.ActionGroupResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -503,9 +508,9 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -528,9 +533,9 @@ def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -548,11 +553,13 @@ def create_or_update( deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}" + } @distributed_trace def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) -> _models.ActionGroupResource: @@ -579,8 +586,8 @@ def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) - _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -592,9 +599,9 @@ def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) - params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -612,7 +619,9 @@ def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) - return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -641,8 +650,8 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -654,9 +663,9 @@ def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -670,7 +679,9 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}" + } @overload def update( @@ -743,8 +754,8 @@ def update( :type resource_group_name: str :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Is either a model type or a IO - type. Required. + :param action_group_patch: Parameters supplied to the operation. Is either a + ActionGroupPatchBody type or a IO type. Required. :type action_group_patch: ~$(python-base-namespace).v2022_04_01.models.ActionGroupPatchBody or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -766,9 +777,9 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -791,9 +802,9 @@ def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -811,7 +822,9 @@ def update( return deserialized - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}" + } def _post_test_notifications_initial( self, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any @@ -827,9 +840,9 @@ def _post_test_notifications_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.TestNotificationDetailsResponse]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -850,9 +863,9 @@ def _post_test_notifications_initial( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -876,7 +889,9 @@ def _post_test_notifications_initial( return deserialized - _post_test_notifications_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications"} # type: ignore + _post_test_notifications_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications" + } @overload def begin_post_test_notifications( @@ -944,7 +959,7 @@ def begin_post_test_notifications( """Send test notifications to a set of provided receivers. :param notification_request: The notification request body which includes the contact details. - Is either a model type or a IO type. Required. + Is either a NotificationRequestBody type or a IO type. Required. :type notification_request: ~$(python-base-namespace).v2022_04_01.models.NotificationRequestBody or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -967,14 +982,14 @@ def begin_post_test_notifications( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._post_test_notifications_initial( # type: ignore + raw_result = self._post_test_notifications_initial( notification_request=notification_request, api_version=api_version, content_type=content_type, @@ -992,9 +1007,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method = cast( + polling_method: PollingMethod = cast( PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) # type: PollingMethod + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: @@ -1006,9 +1021,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_post_test_notifications.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications"} # type: ignore + begin_post_test_notifications.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications" + } def _create_notifications_at_resource_group_level_initial( self, resource_group_name: str, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any @@ -1024,9 +1041,9 @@ def _create_notifications_at_resource_group_level_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.TestNotificationDetailsResponse]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1048,9 +1065,9 @@ def _create_notifications_at_resource_group_level_initial( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -1074,7 +1091,9 @@ def _create_notifications_at_resource_group_level_initial( return deserialized - _create_notifications_at_resource_group_level_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications"} # type: ignore + _create_notifications_at_resource_group_level_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications" + } @overload def begin_create_notifications_at_resource_group_level( @@ -1157,7 +1176,7 @@ def begin_create_notifications_at_resource_group_level( Required. :type resource_group_name: str :param notification_request: The notification request body which includes the contact details. - Is either a model type or a IO type. Required. + Is either a NotificationRequestBody type or a IO type. Required. :type notification_request: ~$(python-base-namespace).v2022_04_01.models.NotificationRequestBody or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -1180,14 +1199,14 @@ def begin_create_notifications_at_resource_group_level( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._create_notifications_at_resource_group_level_initial( # type: ignore + raw_result = self._create_notifications_at_resource_group_level_initial( resource_group_name=resource_group_name, notification_request=notification_request, api_version=api_version, @@ -1206,9 +1225,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method = cast( + polling_method: PollingMethod = cast( PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) # type: PollingMethod + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: @@ -1220,9 +1239,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_notifications_at_resource_group_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications"} # type: ignore + begin_create_notifications_at_resource_group_level.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications" + } @distributed_trace def get_test_notifications(self, notification_id: str, **kwargs: Any) -> _models.TestNotificationDetailsResponse: @@ -1246,8 +1267,8 @@ def get_test_notifications(self, notification_id: str, **kwargs: Any) -> _models _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) request = build_get_test_notifications_request( notification_id=notification_id, @@ -1258,9 +1279,9 @@ def get_test_notifications(self, notification_id: str, **kwargs: Any) -> _models params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -1278,7 +1299,9 @@ def get_test_notifications(self, notification_id: str, **kwargs: Any) -> _models return deserialized - get_test_notifications.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/notificationStatus/{notificationId}"} # type: ignore + get_test_notifications.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/notificationStatus/{notificationId}" + } @distributed_trace def get_test_notifications_at_resource_group_level( @@ -1307,8 +1330,8 @@ def get_test_notifications_at_resource_group_level( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) request = build_get_test_notifications_at_resource_group_level_request( resource_group_name=resource_group_name, @@ -1320,9 +1343,9 @@ def get_test_notifications_at_resource_group_level( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -1340,7 +1363,9 @@ def get_test_notifications_at_resource_group_level( return deserialized - get_test_notifications_at_resource_group_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/notificationStatus/{notificationId}"} # type: ignore + get_test_notifications_at_resource_group_level.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/notificationStatus/{notificationId}" + } @distributed_trace def list_by_subscription_id(self, **kwargs: Any) -> Iterable["_models.ActionGroupResource"]: @@ -1355,8 +1380,8 @@ def list_by_subscription_id(self, **kwargs: Any) -> Iterable["_models.ActionGrou _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -1377,16 +1402,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -1394,13 +1426,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ActionGroupList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1414,7 +1446,9 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_subscription_id.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/actionGroups"} # type: ignore + list_by_subscription_id.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/actionGroups" + } @distributed_trace def list_by_resource_group( @@ -1434,8 +1468,8 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -1457,16 +1491,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -1474,13 +1515,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ActionGroupList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1494,7 +1535,9 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups" + } @overload def enable_receiver( # pylint: disable=inconsistent-return-statements @@ -1570,7 +1613,7 @@ def enable_receiver( # pylint: disable=inconsistent-return-statements :type resource_group_name: str :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param enable_request: The receiver to re-enable. Is either a model type or a IO type. + :param enable_request: The receiver to re-enable. Is either a EnableRequest type or a IO type. Required. :type enable_request: ~$(python-base-namespace).v2022_04_01.models.EnableRequest or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -1592,9 +1635,9 @@ def enable_receiver( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2022-04-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-04-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1617,9 +1660,9 @@ def enable_receiver( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -1633,4 +1676,6 @@ def enable_receiver( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - enable_receiver.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe"} # type: ignore + enable_receiver.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/__init__.py index 8ba4823444a9..2c7733bfd566 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/__init__.py @@ -13,12 +13,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["MonitorManagementClient"] +__all__ = [ + "MonitorManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_configuration.py index 9ce789c9c981..b9c50c775c40 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -36,7 +42,7 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2022-06-01") # type: str + api_version: Literal["2022-06-01"] = kwargs.pop("api_version", "2022-06-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -50,10 +56,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, **kwargs # type: Any - ): - # type: (...) -> None + def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_metadata.json index d6963144f2b6..8c60f1a12836 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_metadata.json @@ -19,13 +19,15 @@ "signature": "credential: \"TokenCredential\",", "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true + "required": true, + "method_location": "positional" }, "subscription_id": { "signature": "subscription_id: str,", "description": "The ID of the target subscription. Required.", "docstring_type": "str", - "required": true + "required": true, + "method_location": "positional" } }, "async": { @@ -48,22 +50,25 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "signature": "api_version: Optional[str]=None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } }, "async": { @@ -71,19 +76,22 @@ "signature": "api_version: Optional[str] = None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { "signature": "profile: KnownProfiles = KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } } } @@ -99,4 +107,4 @@ "operation_groups": { "action_groups": "ActionGroupsOperations" } -} \ No newline at end of file +} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_monitor_management_client.py index 1bb22a9b401d..b76aedc0053d 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_monitor_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from . import models +from . import models as _models from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ActionGroupsOperations @@ -52,7 +52,7 @@ def __init__( ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -80,15 +80,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> MonitorManagementClient + def __enter__(self) -> "MonitorManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_vendor.py index 9aad73fc743e..bd0df84f5319 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_vendor.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_vendor.py @@ -5,6 +5,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import List, cast + from azure.core.pipeline.transport import HttpRequest @@ -22,6 +24,7 @@ def _format_url_section(template, **kwargs): try: return template.format(**kwargs) except KeyError as key: - formatted_components = template.split("/") + # Need the cast, as for some reasons "split" is typed as list[str | Any] + formatted_components = cast(List[str], template.split("/")) components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_version.py index ce9ac7ae37b3..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/__init__.py index 8638dc69d869..2c151bb41c19 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/__init__.py @@ -10,12 +10,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["MonitorManagementClient"] +__all__ = [ + "MonitorManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/_configuration.py index 432effa58c39..8f99f90be32f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -36,7 +42,7 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2022-06-01") # type: str + api_version: Literal["2022-06-01"] = kwargs.pop("api_version", "2022-06-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/_monitor_management_client.py index ef0415ce7660..9b1fbe848988 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/_monitor_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from .. import models +from .. import models as _models from ..._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import ActionGroupsOperations @@ -53,7 +53,7 @@ def __init__( ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -88,5 +88,5 @@ async def __aenter__(self) -> "MonitorManagementClient": await self._client.__aenter__() return self - async def __aexit__(self, *exc_details) -> None: + async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/operations/__init__.py index 0e396f5d7fb0..05f0527dc979 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/operations/__init__.py @@ -9,7 +9,7 @@ from ._action_groups_operations import ActionGroupsOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/operations/_action_groups_operations.py index 070da7afd8ec..815c352508c7 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/operations/_action_groups_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/aio/operations/_action_groups_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -46,6 +47,10 @@ build_update_request, ) +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -140,8 +145,8 @@ async def create_or_update( :type resource_group_name: str :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group: The action group to create or use for the update. Is either a model type - or a IO type. Required. + :param action_group: The action group to create or use for the update. Is either a + ActionGroupResource type or a IO type. Required. :type action_group: ~$(python-base-namespace).v2022_06_01.models.ActionGroupResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -162,9 +167,9 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] + api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -187,9 +192,9 @@ async def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -207,11 +212,13 @@ async def create_or_update( deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}" + } @distributed_trace_async async def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) -> _models.ActionGroupResource: @@ -238,8 +245,8 @@ async def get(self, resource_group_name: str, action_group_name: str, **kwargs: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] + api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -251,9 +258,9 @@ async def get(self, resource_group_name: str, action_group_name: str, **kwargs: params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -271,7 +278,9 @@ async def get(self, resource_group_name: str, action_group_name: str, **kwargs: return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -300,8 +309,8 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -313,9 +322,9 @@ async def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -329,7 +338,9 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}" + } @overload async def update( @@ -402,8 +413,8 @@ async def update( :type resource_group_name: str :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Is either a model type or a IO - type. Required. + :param action_group_patch: Parameters supplied to the operation. Is either a + ActionGroupPatchBody type or a IO type. Required. :type action_group_patch: ~$(python-base-namespace).v2022_06_01.models.ActionGroupPatchBody or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -425,9 +436,9 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] + api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -450,9 +461,9 @@ async def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -470,7 +481,9 @@ async def update( return deserialized - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}" + } async def _post_test_notifications_initial( self, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any @@ -486,9 +499,9 @@ async def _post_test_notifications_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] + api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.TestNotificationDetailsResponse]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -509,9 +522,9 @@ async def _post_test_notifications_initial( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -535,7 +548,9 @@ async def _post_test_notifications_initial( return deserialized - _post_test_notifications_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications"} # type: ignore + _post_test_notifications_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications" + } @overload async def begin_post_test_notifications( @@ -603,7 +618,7 @@ async def begin_post_test_notifications( """Send test notifications to a set of provided receivers. :param notification_request: The notification request body which includes the contact details. - Is either a model type or a IO type. Required. + Is either a NotificationRequestBody type or a IO type. Required. :type notification_request: ~$(python-base-namespace).v2022_06_01.models.NotificationRequestBody or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -626,14 +641,14 @@ async def begin_post_test_notifications( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._post_test_notifications_initial( # type: ignore + raw_result = await self._post_test_notifications_initial( notification_request=notification_request, api_version=api_version, content_type=content_type, @@ -651,9 +666,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method = cast( + polling_method: AsyncPollingMethod = cast( AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) # type: AsyncPollingMethod + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: @@ -665,9 +680,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_post_test_notifications.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications"} # type: ignore + begin_post_test_notifications.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications" + } async def _create_notifications_at_resource_group_level_initial( self, resource_group_name: str, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any @@ -683,9 +700,9 @@ async def _create_notifications_at_resource_group_level_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] + api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.TestNotificationDetailsResponse]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -707,9 +724,9 @@ async def _create_notifications_at_resource_group_level_initial( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -733,7 +750,9 @@ async def _create_notifications_at_resource_group_level_initial( return deserialized - _create_notifications_at_resource_group_level_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications"} # type: ignore + _create_notifications_at_resource_group_level_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications" + } @overload async def begin_create_notifications_at_resource_group_level( @@ -816,7 +835,7 @@ async def begin_create_notifications_at_resource_group_level( Required. :type resource_group_name: str :param notification_request: The notification request body which includes the contact details. - Is either a model type or a IO type. Required. + Is either a NotificationRequestBody type or a IO type. Required. :type notification_request: ~$(python-base-namespace).v2022_06_01.models.NotificationRequestBody or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -839,14 +858,14 @@ async def begin_create_notifications_at_resource_group_level( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._create_notifications_at_resource_group_level_initial( # type: ignore + raw_result = await self._create_notifications_at_resource_group_level_initial( resource_group_name=resource_group_name, notification_request=notification_request, api_version=api_version, @@ -865,9 +884,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method = cast( + polling_method: AsyncPollingMethod = cast( AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) # type: AsyncPollingMethod + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: @@ -879,9 +898,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_notifications_at_resource_group_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications"} # type: ignore + begin_create_notifications_at_resource_group_level.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications" + } async def _create_notifications_at_action_group_resource_level_initial( self, @@ -901,9 +922,9 @@ async def _create_notifications_at_action_group_resource_level_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] + api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.TestNotificationDetailsResponse]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -926,9 +947,9 @@ async def _create_notifications_at_action_group_resource_level_initial( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -952,7 +973,9 @@ async def _create_notifications_at_action_group_resource_level_initial( return deserialized - _create_notifications_at_action_group_resource_level_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications"} # type: ignore + _create_notifications_at_action_group_resource_level_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications" + } @overload async def begin_create_notifications_at_action_group_resource_level( @@ -1047,7 +1070,7 @@ async def begin_create_notifications_at_action_group_resource_level( :param action_group_name: The name of the action group. Required. :type action_group_name: str :param notification_request: The notification request body which includes the contact details. - Is either a model type or a IO type. Required. + Is either a NotificationRequestBody type or a IO type. Required. :type notification_request: ~$(python-base-namespace).v2022_06_01.models.NotificationRequestBody or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -1070,14 +1093,14 @@ async def begin_create_notifications_at_action_group_resource_level( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = await self._create_notifications_at_action_group_resource_level_initial( # type: ignore + raw_result = await self._create_notifications_at_action_group_resource_level_initial( resource_group_name=resource_group_name, action_group_name=action_group_name, notification_request=notification_request, @@ -1097,9 +1120,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method = cast( + polling_method: AsyncPollingMethod = cast( AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) # type: AsyncPollingMethod + ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: @@ -1111,9 +1134,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output, ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_notifications_at_action_group_resource_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications"} # type: ignore + begin_create_notifications_at_action_group_resource_level.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications" + } @distributed_trace_async async def get_test_notifications( @@ -1139,8 +1164,8 @@ async def get_test_notifications( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] + api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) request = build_get_test_notifications_request( notification_id=notification_id, @@ -1151,9 +1176,9 @@ async def get_test_notifications( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -1171,7 +1196,9 @@ async def get_test_notifications( return deserialized - get_test_notifications.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/notificationStatus/{notificationId}"} # type: ignore + get_test_notifications.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/notificationStatus/{notificationId}" + } @distributed_trace_async async def get_test_notifications_at_resource_group_level( @@ -1200,8 +1227,8 @@ async def get_test_notifications_at_resource_group_level( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] + api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) request = build_get_test_notifications_at_resource_group_level_request( resource_group_name=resource_group_name, @@ -1213,9 +1240,9 @@ async def get_test_notifications_at_resource_group_level( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -1233,7 +1260,9 @@ async def get_test_notifications_at_resource_group_level( return deserialized - get_test_notifications_at_resource_group_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/notificationStatus/{notificationId}"} # type: ignore + get_test_notifications_at_resource_group_level.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/notificationStatus/{notificationId}" + } @distributed_trace_async async def get_test_notifications_at_action_group_resource_level( @@ -1264,8 +1293,8 @@ async def get_test_notifications_at_action_group_resource_level( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] + api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) request = build_get_test_notifications_at_action_group_resource_level_request( resource_group_name=resource_group_name, @@ -1278,9 +1307,9 @@ async def get_test_notifications_at_action_group_resource_level( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -1298,7 +1327,9 @@ async def get_test_notifications_at_action_group_resource_level( return deserialized - get_test_notifications_at_action_group_resource_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/notificationStatus/{notificationId}"} # type: ignore + get_test_notifications_at_action_group_resource_level.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/notificationStatus/{notificationId}" + } @distributed_trace def list_by_subscription_id(self, **kwargs: Any) -> AsyncIterable["_models.ActionGroupResource"]: @@ -1313,8 +1344,8 @@ def list_by_subscription_id(self, **kwargs: Any) -> AsyncIterable["_models.Actio _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -1335,16 +1366,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -1352,13 +1390,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ActionGroupList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1372,7 +1410,9 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_subscription_id.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/actionGroups"} # type: ignore + list_by_subscription_id.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/actionGroups" + } @distributed_trace def list_by_resource_group( @@ -1392,8 +1432,8 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -1415,16 +1455,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -1432,13 +1479,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("ActionGroupList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1452,7 +1499,9 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups" + } @overload async def enable_receiver( # pylint: disable=inconsistent-return-statements @@ -1528,7 +1577,7 @@ async def enable_receiver( # pylint: disable=inconsistent-return-statements :type resource_group_name: str :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param enable_request: The receiver to re-enable. Is either a model type or a IO type. + :param enable_request: The receiver to re-enable. Is either a EnableRequest type or a IO type. Required. :type enable_request: ~$(python-base-namespace).v2022_06_01.models.EnableRequest or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -1550,9 +1599,9 @@ async def enable_receiver( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1575,9 +1624,9 @@ async def enable_receiver( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -1591,4 +1640,6 @@ async def enable_receiver( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - enable_receiver.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe"} # type: ignore + enable_receiver.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/models/__init__.py index c2c49e9b3b64..b1dac637c403 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/models/__init__.py @@ -30,7 +30,7 @@ from ._monitor_management_client_enums import ReceiverStatus from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/models/_models_py3.py index 81c81c3f5157..0d265468a543 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/models/_models_py3.py @@ -7,7 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Dict, List, Optional, TYPE_CHECKING +from typing import Any, Dict, List, Optional, TYPE_CHECKING from ... import _serialization @@ -51,8 +51,8 @@ def __init__( sub_state: Optional[str] = None, send_time: Optional[str] = None, detail: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword mechanism_type: The mechanism type. :paramtype mechanism_type: str @@ -91,8 +91,12 @@ class ActionGroupList(_serialization.Model): } def __init__( - self, *, value: Optional[List["_models.ActionGroupResource"]] = None, next_link: Optional[str] = None, **kwargs - ): + self, + *, + value: Optional[List["_models.ActionGroupResource"]] = None, + next_link: Optional[str] = None, + **kwargs: Any + ) -> None: """ :keyword value: The list of action groups. :paramtype value: list[~$(python-base-namespace).v2022_06_01.models.ActionGroupResource] @@ -119,7 +123,7 @@ class ActionGroupPatchBody(_serialization.Model): "enabled": {"key": "properties.enabled", "type": "bool"}, } - def __init__(self, *, tags: Optional[Dict[str, str]] = None, enabled: bool = True, **kwargs): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, enabled: bool = True, **kwargs: Any) -> None: """ :keyword tags: Resource tags. :paramtype tags: dict[str, str] @@ -166,7 +170,7 @@ class AzureResource(_serialization.Model): "tags": {"key": "tags", "type": "{str}"}, } - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: """ :keyword location: Resource location. Required. :paramtype location: str @@ -286,8 +290,8 @@ def __init__( azure_function_receivers: Optional[List["_models.AzureFunctionReceiver"]] = None, arm_role_receivers: Optional[List["_models.ArmRoleReceiver"]] = None, event_hub_receivers: Optional[List["_models.EventHubReceiver"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword location: Resource location. Required. :paramtype location: str @@ -376,7 +380,7 @@ class ArmRoleReceiver(_serialization.Model): "use_common_alert_schema": {"key": "useCommonAlertSchema", "type": "bool"}, } - def __init__(self, *, name: str, role_id: str, use_common_alert_schema: bool = False, **kwargs): + def __init__(self, *, name: str, role_id: str, use_common_alert_schema: bool = False, **kwargs: Any) -> None: """ :keyword name: The name of the arm role receiver. Names must be unique across all receivers within an action group. Required. @@ -441,8 +445,8 @@ def __init__( name: Optional[str] = None, service_uri: Optional[str] = None, use_common_alert_schema: bool = False, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword automation_account_id: The Azure automation account Id which holds this runbook and authenticate to Azure resource. Required. @@ -492,7 +496,7 @@ class AzureAppPushReceiver(_serialization.Model): "email_address": {"key": "emailAddress", "type": "str"}, } - def __init__(self, *, name: str, email_address: str, **kwargs): + def __init__(self, *, name: str, email_address: str, **kwargs: Any) -> None: """ :keyword name: The name of the Azure mobile app push receiver. Names must be unique across all receivers within an action group. Required. @@ -546,8 +550,8 @@ def __init__( function_name: str, http_trigger_url: str, use_common_alert_schema: bool = False, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: The name of the azure function receiver. Names must be unique across all receivers within an action group. Required. @@ -583,7 +587,9 @@ class Context(_serialization.Model): "context_type": {"key": "contextType", "type": "str"}, } - def __init__(self, *, notification_source: Optional[str] = None, context_type: Optional[str] = None, **kwargs): + def __init__( + self, *, notification_source: Optional[str] = None, context_type: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword notification_source: The source of the notification request. :paramtype notification_source: str @@ -627,7 +633,7 @@ class EmailReceiver(_serialization.Model): "status": {"key": "status", "type": "str"}, } - def __init__(self, *, name: str, email_address: str, use_common_alert_schema: bool = False, **kwargs): + def __init__(self, *, name: str, email_address: str, use_common_alert_schema: bool = False, **kwargs: Any) -> None: """ :keyword name: The name of the email receiver. Names must be unique across all receivers within an action group. Required. @@ -661,7 +667,7 @@ class EnableRequest(_serialization.Model): "receiver_name": {"key": "receiverName", "type": "str"}, } - def __init__(self, *, receiver_name: str, **kwargs): + def __init__(self, *, receiver_name: str, **kwargs: Any) -> None: """ :keyword receiver_name: The name of the receiver to resubscribe. Required. :paramtype receiver_name: str @@ -684,7 +690,7 @@ class ErrorResponse(_serialization.Model): "message": {"key": "message", "type": "str"}, } - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs: Any) -> None: """ :keyword code: Error code. :paramtype code: str @@ -741,8 +747,8 @@ def __init__( subscription_id: str, use_common_alert_schema: bool = False, tenant_id: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: The name of the Event hub receiver. Names must be unique across all receivers within an action group. Required. @@ -806,8 +812,8 @@ class ItsmReceiver(_serialization.Model): } def __init__( - self, *, name: str, workspace_id: str, connection_id: str, ticket_configuration: str, region: str, **kwargs - ): + self, *, name: str, workspace_id: str, connection_id: str, ticket_configuration: str, region: str, **kwargs: Any + ) -> None: """ :keyword name: The name of the Itsm receiver. Names must be unique across all receivers within an action group. Required. @@ -863,8 +869,8 @@ class LogicAppReceiver(_serialization.Model): } def __init__( - self, *, name: str, resource_id: str, callback_url: str, use_common_alert_schema: bool = False, **kwargs - ): + self, *, name: str, resource_id: str, callback_url: str, use_common_alert_schema: bool = False, **kwargs: Any + ) -> None: """ :keyword name: The name of the logic app receiver. Names must be unique across all receivers within an action group. Required. @@ -891,7 +897,7 @@ class NotificationRequestBody(_serialization.Model): # pylint: disable=too-many :ivar alert_type: The value of the supported alert type. Supported alert type values are: servicehealth, metricstaticthreshold, metricsdynamicthreshold, logalertv2, smartalert, webtestalert, logalertv1numresult, logalertv1metricmeasurement, resourcehealth, activitylog, - budget. Required. + actualcostbudget, forecastedbudget. Required. :vartype alert_type: str :ivar email_receivers: The list of email receivers that are part of this action group. :vartype email_receivers: list[~$(python-base-namespace).v2022_06_01.models.EmailReceiver] @@ -960,13 +966,13 @@ def __init__( azure_function_receivers: Optional[List["_models.AzureFunctionReceiver"]] = None, arm_role_receivers: Optional[List["_models.ArmRoleReceiver"]] = None, event_hub_receivers: Optional[List["_models.EventHubReceiver"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword alert_type: The value of the supported alert type. Supported alert type values are: servicehealth, metricstaticthreshold, metricsdynamicthreshold, logalertv2, smartalert, webtestalert, logalertv1numresult, logalertv1metricmeasurement, resourcehealth, activitylog, - budget. Required. + actualcostbudget, forecastedbudget. Required. :paramtype alert_type: str :keyword email_receivers: The list of email receivers that are part of this action group. :paramtype email_receivers: list[~$(python-base-namespace).v2022_06_01.models.EmailReceiver] @@ -1052,7 +1058,7 @@ class SmsReceiver(_serialization.Model): "status": {"key": "status", "type": "str"}, } - def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs): + def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs: Any) -> None: """ :keyword name: The name of the SMS receiver. Names must be unique across all receivers within an action group. Required. @@ -1106,8 +1112,8 @@ def __init__( completed_time: Optional[str] = None, created_time: Optional[str] = None, action_details: Optional[List["_models.ActionDetail"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword context: The context info. :paramtype context: ~$(python-base-namespace).v2022_06_01.models.Context @@ -1154,7 +1160,7 @@ class VoiceReceiver(_serialization.Model): "phone_number": {"key": "phoneNumber", "type": "str"}, } - def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs): + def __init__(self, *, name: str, country_code: str, phone_number: str, **kwargs: Any) -> None: """ :keyword name: The name of the voice receiver. Names must be unique across all receivers within an action group. Required. @@ -1217,8 +1223,8 @@ def __init__( object_id: Optional[str] = None, identifier_uri: Optional[str] = None, tenant_id: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: The name of the webhook receiver. Names must be unique across all receivers within an action group. Required. diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/operations/__init__.py index 0e396f5d7fb0..05f0527dc979 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/operations/__init__.py @@ -9,7 +9,7 @@ from ._action_groups_operations import ActionGroupsOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/operations/_action_groups_operations.py index 655831be41e5..f6fd9eb2fab6 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/operations/_action_groups_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_06_01/operations/_action_groups_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -31,6 +32,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -44,8 +49,8 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -61,7 +66,7 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -80,7 +85,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str + api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -96,7 +101,7 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -113,7 +118,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str + api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -129,7 +134,7 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -146,8 +151,8 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -163,7 +168,7 @@ def build_update_request( "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -180,8 +185,8 @@ def build_post_test_notifications_request(subscription_id: str, **kwargs: Any) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -192,7 +197,7 @@ def build_post_test_notifications_request(subscription_id: str, **kwargs: Any) - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -211,8 +216,8 @@ def build_create_notifications_at_resource_group_level_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -227,7 +232,7 @@ def build_create_notifications_at_resource_group_level_request( ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -246,8 +251,8 @@ def build_create_notifications_at_action_group_resource_level_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -263,7 +268,7 @@ def build_create_notifications_at_action_group_resource_level_request( "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -280,7 +285,7 @@ def build_get_test_notifications_request(notification_id: str, subscription_id: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str + api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -293,7 +298,7 @@ def build_get_test_notifications_request(notification_id: str, subscription_id: "notificationId": _SERIALIZER.url("notification_id", notification_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -310,7 +315,7 @@ def build_get_test_notifications_at_resource_group_level_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str + api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -326,7 +331,7 @@ def build_get_test_notifications_at_resource_group_level_request( "notificationId": _SERIALIZER.url("notification_id", notification_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -343,7 +348,7 @@ def build_get_test_notifications_at_action_group_resource_level_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str + api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -360,7 +365,7 @@ def build_get_test_notifications_at_action_group_resource_level_request( "notificationId": _SERIALIZER.url("notification_id", notification_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -375,7 +380,7 @@ def build_list_by_subscription_id_request(subscription_id: str, **kwargs: Any) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str + api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -384,7 +389,7 @@ def build_list_by_subscription_id_request(subscription_id: str, **kwargs: Any) - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -399,7 +404,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str + api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -414,7 +419,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -431,8 +436,8 @@ def build_enable_receiver_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -448,7 +453,7 @@ def build_enable_receiver_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -551,8 +556,8 @@ def create_or_update( :type resource_group_name: str :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group: The action group to create or use for the update. Is either a model type - or a IO type. Required. + :param action_group: The action group to create or use for the update. Is either a + ActionGroupResource type or a IO type. Required. :type action_group: ~$(python-base-namespace).v2022_06_01.models.ActionGroupResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -573,9 +578,9 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] + api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -598,9 +603,9 @@ def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -618,11 +623,13 @@ def create_or_update( deserialized = self._deserialize("ActionGroupResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}" + } @distributed_trace def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) -> _models.ActionGroupResource: @@ -649,8 +656,8 @@ def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) - _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] + api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -662,9 +669,9 @@ def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) - params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -682,7 +689,9 @@ def get(self, resource_group_name: str, action_group_name: str, **kwargs: Any) - return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -711,8 +720,8 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -724,9 +733,9 @@ def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -740,7 +749,9 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}" + } @overload def update( @@ -813,8 +824,8 @@ def update( :type resource_group_name: str :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param action_group_patch: Parameters supplied to the operation. Is either a model type or a IO - type. Required. + :param action_group_patch: Parameters supplied to the operation. Is either a + ActionGroupPatchBody type or a IO type. Required. :type action_group_patch: ~$(python-base-namespace).v2022_06_01.models.ActionGroupPatchBody or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -836,9 +847,9 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupResource] + api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ActionGroupResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -861,9 +872,9 @@ def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -881,7 +892,9 @@ def update( return deserialized - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}" + } def _post_test_notifications_initial( self, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any @@ -897,9 +910,9 @@ def _post_test_notifications_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] + api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.TestNotificationDetailsResponse]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -920,9 +933,9 @@ def _post_test_notifications_initial( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -946,7 +959,9 @@ def _post_test_notifications_initial( return deserialized - _post_test_notifications_initial.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications"} # type: ignore + _post_test_notifications_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications" + } @overload def begin_post_test_notifications( @@ -1014,7 +1029,7 @@ def begin_post_test_notifications( """Send test notifications to a set of provided receivers. :param notification_request: The notification request body which includes the contact details. - Is either a model type or a IO type. Required. + Is either a NotificationRequestBody type or a IO type. Required. :type notification_request: ~$(python-base-namespace).v2022_06_01.models.NotificationRequestBody or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -1037,14 +1052,14 @@ def begin_post_test_notifications( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._post_test_notifications_initial( # type: ignore + raw_result = self._post_test_notifications_initial( notification_request=notification_request, api_version=api_version, content_type=content_type, @@ -1062,9 +1077,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method = cast( + polling_method: PollingMethod = cast( PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) # type: PollingMethod + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: @@ -1076,9 +1091,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_post_test_notifications.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications"} # type: ignore + begin_post_test_notifications.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications" + } def _create_notifications_at_resource_group_level_initial( self, resource_group_name: str, notification_request: Union[_models.NotificationRequestBody, IO], **kwargs: Any @@ -1094,9 +1111,9 @@ def _create_notifications_at_resource_group_level_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] + api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.TestNotificationDetailsResponse]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1118,9 +1135,9 @@ def _create_notifications_at_resource_group_level_initial( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -1144,7 +1161,9 @@ def _create_notifications_at_resource_group_level_initial( return deserialized - _create_notifications_at_resource_group_level_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications"} # type: ignore + _create_notifications_at_resource_group_level_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications" + } @overload def begin_create_notifications_at_resource_group_level( @@ -1227,7 +1246,7 @@ def begin_create_notifications_at_resource_group_level( Required. :type resource_group_name: str :param notification_request: The notification request body which includes the contact details. - Is either a model type or a IO type. Required. + Is either a NotificationRequestBody type or a IO type. Required. :type notification_request: ~$(python-base-namespace).v2022_06_01.models.NotificationRequestBody or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -1250,14 +1269,14 @@ def begin_create_notifications_at_resource_group_level( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._create_notifications_at_resource_group_level_initial( # type: ignore + raw_result = self._create_notifications_at_resource_group_level_initial( resource_group_name=resource_group_name, notification_request=notification_request, api_version=api_version, @@ -1276,9 +1295,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method = cast( + polling_method: PollingMethod = cast( PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) # type: PollingMethod + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: @@ -1290,9 +1309,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_notifications_at_resource_group_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications"} # type: ignore + begin_create_notifications_at_resource_group_level.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/createNotifications" + } def _create_notifications_at_action_group_resource_level_initial( self, @@ -1312,9 +1333,9 @@ def _create_notifications_at_action_group_resource_level_initial( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.TestNotificationDetailsResponse]] + api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Optional[_models.TestNotificationDetailsResponse]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1337,9 +1358,9 @@ def _create_notifications_at_action_group_resource_level_initial( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -1363,7 +1384,9 @@ def _create_notifications_at_action_group_resource_level_initial( return deserialized - _create_notifications_at_action_group_resource_level_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications"} # type: ignore + _create_notifications_at_action_group_resource_level_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications" + } @overload def begin_create_notifications_at_action_group_resource_level( @@ -1458,7 +1481,7 @@ def begin_create_notifications_at_action_group_resource_level( :param action_group_name: The name of the action group. Required. :type action_group_name: str :param notification_request: The notification request body which includes the contact details. - Is either a model type or a IO type. Required. + Is either a NotificationRequestBody type or a IO type. Required. :type notification_request: ~$(python-base-namespace).v2022_06_01.models.NotificationRequestBody or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -1481,14 +1504,14 @@ def begin_create_notifications_at_action_group_resource_level( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: - raw_result = self._create_notifications_at_action_group_resource_level_initial( # type: ignore + raw_result = self._create_notifications_at_action_group_resource_level_initial( resource_group_name=resource_group_name, action_group_name=action_group_name, notification_request=notification_request, @@ -1508,9 +1531,9 @@ def get_long_running_output(pipeline_response): return deserialized if polling is True: - polling_method = cast( + polling_method: PollingMethod = cast( PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) - ) # type: PollingMethod + ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: @@ -1522,9 +1545,11 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output, ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore - begin_create_notifications_at_action_group_resource_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications"} # type: ignore + begin_create_notifications_at_action_group_resource_level.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/createNotifications" + } @distributed_trace def get_test_notifications(self, notification_id: str, **kwargs: Any) -> _models.TestNotificationDetailsResponse: @@ -1548,8 +1573,8 @@ def get_test_notifications(self, notification_id: str, **kwargs: Any) -> _models _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] + api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) request = build_get_test_notifications_request( notification_id=notification_id, @@ -1560,9 +1585,9 @@ def get_test_notifications(self, notification_id: str, **kwargs: Any) -> _models params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -1580,7 +1605,9 @@ def get_test_notifications(self, notification_id: str, **kwargs: Any) -> _models return deserialized - get_test_notifications.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/notificationStatus/{notificationId}"} # type: ignore + get_test_notifications.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/notificationStatus/{notificationId}" + } @distributed_trace def get_test_notifications_at_resource_group_level( @@ -1609,8 +1636,8 @@ def get_test_notifications_at_resource_group_level( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] + api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) request = build_get_test_notifications_at_resource_group_level_request( resource_group_name=resource_group_name, @@ -1622,9 +1649,9 @@ def get_test_notifications_at_resource_group_level( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -1642,7 +1669,9 @@ def get_test_notifications_at_resource_group_level( return deserialized - get_test_notifications_at_resource_group_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/notificationStatus/{notificationId}"} # type: ignore + get_test_notifications_at_resource_group_level.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/notificationStatus/{notificationId}" + } @distributed_trace def get_test_notifications_at_action_group_resource_level( @@ -1673,8 +1702,8 @@ def get_test_notifications_at_action_group_resource_level( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.TestNotificationDetailsResponse] + api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + cls: ClsType[_models.TestNotificationDetailsResponse] = kwargs.pop("cls", None) request = build_get_test_notifications_at_action_group_resource_level_request( resource_group_name=resource_group_name, @@ -1687,9 +1716,9 @@ def get_test_notifications_at_action_group_resource_level( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -1707,7 +1736,9 @@ def get_test_notifications_at_action_group_resource_level( return deserialized - get_test_notifications_at_action_group_resource_level.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/notificationStatus/{notificationId}"} # type: ignore + get_test_notifications_at_action_group_resource_level.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/notificationStatus/{notificationId}" + } @distributed_trace def list_by_subscription_id(self, **kwargs: Any) -> Iterable["_models.ActionGroupResource"]: @@ -1722,8 +1753,8 @@ def list_by_subscription_id(self, **kwargs: Any) -> Iterable["_models.ActionGrou _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -1744,16 +1775,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -1761,13 +1799,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ActionGroupList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1781,7 +1819,9 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_subscription_id.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/actionGroups"} # type: ignore + list_by_subscription_id.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/actionGroups" + } @distributed_trace def list_by_resource_group( @@ -1801,8 +1841,8 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.ActionGroupList] + api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + cls: ClsType[_models.ActionGroupList] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -1824,16 +1864,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -1841,13 +1888,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("ActionGroupList", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1861,7 +1908,9 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups" + } @overload def enable_receiver( # pylint: disable=inconsistent-return-statements @@ -1937,7 +1986,7 @@ def enable_receiver( # pylint: disable=inconsistent-return-statements :type resource_group_name: str :param action_group_name: The name of the action group. Required. :type action_group_name: str - :param enable_request: The receiver to re-enable. Is either a model type or a IO type. + :param enable_request: The receiver to re-enable. Is either a EnableRequest type or a IO type. Required. :type enable_request: ~$(python-base-namespace).v2022_06_01.models.EnableRequest or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -1959,9 +2008,9 @@ def enable_receiver( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2022-06-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[None] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1984,9 +2033,9 @@ def enable_receiver( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -2000,4 +2049,6 @@ def enable_receiver( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - enable_receiver.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe"} # type: ignore + enable_receiver.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/__init__.py new file mode 100644 index 000000000000..2c7733bfd566 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/__init__.py @@ -0,0 +1,26 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._monitor_management_client import MonitorManagementClient +from ._version import VERSION + +__version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "MonitorManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/_configuration.py new file mode 100644 index 000000000000..24f1af84e5d2 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/_configuration.py @@ -0,0 +1,72 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +import sys +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for MonitorManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2022-08-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(MonitorManagementClientConfiguration, self).__init__(**kwargs) + api_version: Literal["2022-08-01-preview"] = kwargs.pop("api_version", "2022-08-01-preview") + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) + self._configure(**kwargs) + + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") + if self.credential and not self.authentication_policy: + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/_metadata.json new file mode 100644 index 000000000000..c6ef20d862a8 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/_metadata.json @@ -0,0 +1,110 @@ +{ + "chosen_version": "2022-08-01-preview", + "total_api_version_list": ["2022-08-01-preview"], + "client": { + "name": "MonitorManagementClient", + "filename": "_monitor_management_client", + "description": "Monitor Management Client.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, + "azure_arm": true, + "has_lro_operations": false, + "client_side_validation": false, + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "global_parameters": { + "sync": { + "credential": { + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true, + "method_location": "positional" + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", + "docstring_type": "str", + "required": true, + "method_location": "positional" + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version: Optional[str]=None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "profile": { + "signature": "profile: KnownProfiles=KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false, + "method_location": "positional" + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false, + "method_location": "positional" + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false, + "method_location": "positional" + } + } + } + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"], + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "scheduled_query_rules": "ScheduledQueryRulesOperations" + } +} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/_monitor_management_client.py new file mode 100644 index 000000000000..af420786dcb1 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/_monitor_management_client.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. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, TYPE_CHECKING + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient + +from . import models as _models +from .._serialization import Deserializer, Serializer +from ._configuration import MonitorManagementClientConfiguration +from .operations import ScheduledQueryRulesOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword + """Monitor Management Client. + + :ivar scheduled_query_rules: ScheduledQueryRulesOperations operations + :vartype scheduled_query_rules: + $(python-base-namespace).v2022_08_01_preview.operations.ScheduledQueryRulesOperations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2022-08-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = MonitorManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.scheduled_query_rules = ScheduledQueryRulesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self) -> None: + self._client.close() + + def __enter__(self) -> "MonitorManagementClient": + self._client.__enter__() + return self + + def __exit__(self, *exc_details: Any) -> None: + self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/_vendor.py new file mode 100644 index 000000000000..bd0df84f5319 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/_vendor.py @@ -0,0 +1,30 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import List, cast + +from azure.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + # Need the cast, as for some reasons "split" is typed as list[str | Any] + formatted_components = cast(List[str], template.split("/")) + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] + template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/aio/__init__.py new file mode 100644 index 000000000000..2c151bb41c19 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/aio/__init__.py @@ -0,0 +1,23 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._monitor_management_client import MonitorManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "MonitorManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/aio/_configuration.py new file mode 100644 index 000000000000..93de7bfe09ae --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/aio/_configuration.py @@ -0,0 +1,72 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +import sys +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class MonitorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for MonitorManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2022-08-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: + super(MonitorManagementClientConfiguration, self).__init__(**kwargs) + api_version: Literal["2022-08-01-preview"] = kwargs.pop("api_version", "2022-08-01-preview") + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) + self._configure(**kwargs) + + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") + if self.credential and not self.authentication_policy: + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/aio/_monitor_management_client.py new file mode 100644 index 000000000000..80dc5730de29 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/aio/_monitor_management_client.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. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models as _models +from ..._serialization import Deserializer, Serializer +from ._configuration import MonitorManagementClientConfiguration +from .operations import ScheduledQueryRulesOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class MonitorManagementClient: # pylint: disable=client-accepts-api-version-keyword + """Monitor Management Client. + + :ivar scheduled_query_rules: ScheduledQueryRulesOperations operations + :vartype scheduled_query_rules: + $(python-base-namespace).v2022_08_01_preview.aio.operations.ScheduledQueryRulesOperations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2022-08-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = MonitorManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.scheduled_query_rules = ScheduledQueryRulesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "MonitorManagementClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details: Any) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/aio/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/aio/operations/__init__.py new file mode 100644 index 000000000000..e010c281d4fc --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/aio/operations/__init__.py @@ -0,0 +1,19 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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 ._scheduled_query_rules_operations import ScheduledQueryRulesOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ScheduledQueryRulesOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/aio/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/aio/operations/_scheduled_query_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/aio/operations/_scheduled_query_rules_operations.py new file mode 100644 index 000000000000..5ef2c64da7a9 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/aio/operations/_scheduled_query_rules_operations.py @@ -0,0 +1,666 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._scheduled_query_rules_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_update_request, +) + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ScheduledQueryRulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2022_08_01_preview.aio.MonitorManagementClient`'s + :attr:`scheduled_query_rules` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.ScheduledQueryRuleResource"]: + """Retrieve a scheduled query rule definitions in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ScheduledQueryRuleResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2022_08_01_preview.models.ScheduledQueryRuleResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) + cls: ClsType[_models.ScheduledQueryRuleResourceCollection] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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("ScheduledQueryRuleResourceCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/scheduledQueryRules" + } + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ScheduledQueryRuleResource"]: + """Retrieve scheduled query rule definitions 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ScheduledQueryRuleResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2022_08_01_preview.models.ScheduledQueryRuleResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) + cls: ClsType[_models.ScheduledQueryRuleResourceCollection] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ScheduledQueryRuleResourceCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules" + } + + @distributed_trace_async + async def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _models.ScheduledQueryRuleResource: + """Retrieve an scheduled query rule definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ScheduledQueryRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_08_01_preview.models.ScheduledQueryRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) + cls: ClsType[_models.ScheduledQueryRuleResource] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ScheduledQueryRuleResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}" + } + + @overload + async def create_or_update( + self, + resource_group_name: str, + rule_name: str, + parameters: _models.ScheduledQueryRuleResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ScheduledQueryRuleResource: + """Creates or updates a scheduled query rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to create or update. Required. + :type parameters: + ~$(python-base-namespace).v2022_08_01_preview.models.ScheduledQueryRuleResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ScheduledQueryRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_08_01_preview.models.ScheduledQueryRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ScheduledQueryRuleResource: + """Creates or updates a scheduled query rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to create or update. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ScheduledQueryRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_08_01_preview.models.ScheduledQueryRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + rule_name: str, + parameters: Union[_models.ScheduledQueryRuleResource, IO], + **kwargs: Any + ) -> _models.ScheduledQueryRuleResource: + """Creates or updates a scheduled query rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to create or update. Is either a + ScheduledQueryRuleResource type or a IO type. Required. + :type parameters: + ~$(python-base-namespace).v2022_08_01_preview.models.ScheduledQueryRuleResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ScheduledQueryRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_08_01_preview.models.ScheduledQueryRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScheduledQueryRuleResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScheduledQueryRuleResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ScheduledQueryRuleResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ScheduledQueryRuleResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}" + } + + @overload + async def update( + self, + resource_group_name: str, + rule_name: str, + parameters: _models.ScheduledQueryRuleResourcePatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ScheduledQueryRuleResource: + """Update a scheduled query rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to update. Required. + :type parameters: + ~$(python-base-namespace).v2022_08_01_preview.models.ScheduledQueryRuleResourcePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ScheduledQueryRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_08_01_preview.models.ScheduledQueryRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ScheduledQueryRuleResource: + """Update a scheduled query rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to update. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ScheduledQueryRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_08_01_preview.models.ScheduledQueryRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + rule_name: str, + parameters: Union[_models.ScheduledQueryRuleResourcePatch, IO], + **kwargs: Any + ) -> _models.ScheduledQueryRuleResource: + """Update a scheduled query rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to update. Is either a + ScheduledQueryRuleResourcePatch type or a IO type. Required. + :type parameters: + ~$(python-base-namespace).v2022_08_01_preview.models.ScheduledQueryRuleResourcePatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ScheduledQueryRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_08_01_preview.models.ScheduledQueryRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScheduledQueryRuleResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScheduledQueryRuleResourcePatch") + + request = build_update_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ScheduledQueryRuleResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}" + } + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, rule_name: str, **kwargs: Any + ) -> None: + """Deletes a scheduled query rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/models/__init__.py new file mode 100644 index 000000000000..2fbbffcd5469 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/models/__init__.py @@ -0,0 +1,63 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._models_py3 import Actions +from ._models_py3 import Condition +from ._models_py3 import ConditionFailingPeriods +from ._models_py3 import Dimension +from ._models_py3 import ErrorContract +from ._models_py3 import ErrorResponseAdditionalInfo +from ._models_py3 import ErrorResponseDetails +from ._models_py3 import Identity +from ._models_py3 import RuleResolveConfiguration +from ._models_py3 import ScheduledQueryRuleCriteria +from ._models_py3 import ScheduledQueryRuleResource +from ._models_py3 import ScheduledQueryRuleResourceCollection +from ._models_py3 import ScheduledQueryRuleResourcePatch +from ._models_py3 import SystemData +from ._models_py3 import UserIdentityProperties + +from ._monitor_management_client_enums import AlertSeverity +from ._monitor_management_client_enums import ConditionOperator +from ._monitor_management_client_enums import CreatedByType +from ._monitor_management_client_enums import DimensionOperator +from ._monitor_management_client_enums import IdentityType +from ._monitor_management_client_enums import Kind +from ._monitor_management_client_enums import PublicNetworkAccess +from ._monitor_management_client_enums import TimeAggregation +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "Actions", + "Condition", + "ConditionFailingPeriods", + "Dimension", + "ErrorContract", + "ErrorResponseAdditionalInfo", + "ErrorResponseDetails", + "Identity", + "RuleResolveConfiguration", + "ScheduledQueryRuleCriteria", + "ScheduledQueryRuleResource", + "ScheduledQueryRuleResourceCollection", + "ScheduledQueryRuleResourcePatch", + "SystemData", + "UserIdentityProperties", + "AlertSeverity", + "ConditionOperator", + "CreatedByType", + "DimensionOperator", + "IdentityType", + "Kind", + "PublicNetworkAccess", + "TimeAggregation", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/models/_models_py3.py new file mode 100644 index 000000000000..92bbed4fb0d7 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/models/_models_py3.py @@ -0,0 +1,1059 @@ +# coding=utf-8 +# pylint: disable=too-many-lines +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +import datetime +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union + +from ... import _serialization + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models + + +class Actions(_serialization.Model): + """Actions to invoke when the alert fires. + + :ivar action_groups: Action Group resource Ids to invoke when the alert fires. + :vartype action_groups: list[str] + :ivar custom_properties: The properties of an alert payload. + :vartype custom_properties: dict[str, str] + """ + + _attribute_map = { + "action_groups": {"key": "actionGroups", "type": "[str]"}, + "custom_properties": {"key": "customProperties", "type": "{str}"}, + } + + def __init__( + self, + *, + action_groups: Optional[List[str]] = None, + custom_properties: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword action_groups: Action Group resource Ids to invoke when the alert fires. + :paramtype action_groups: list[str] + :keyword custom_properties: The properties of an alert payload. + :paramtype custom_properties: dict[str, str] + """ + super().__init__(**kwargs) + self.action_groups = action_groups + self.custom_properties = custom_properties + + +class Condition(_serialization.Model): + """A condition of the scheduled query rule. + + :ivar query: Log query alert. + :vartype query: str + :ivar time_aggregation: Aggregation type. Relevant and required only for rules of the kind + LogAlert. Known values are: "Count", "Average", "Minimum", "Maximum", and "Total". + :vartype time_aggregation: str or + ~$(python-base-namespace).v2022_08_01_preview.models.TimeAggregation + :ivar metric_measure_column: The column containing the metric measure number. Relevant only for + rules of the kind LogAlert. + :vartype metric_measure_column: str + :ivar resource_id_column: The column containing the resource id. The content of the column must + be a uri formatted as resource id. Relevant only for rules of the kind LogAlert. + :vartype resource_id_column: str + :ivar dimensions: List of Dimensions conditions. + :vartype dimensions: list[~$(python-base-namespace).v2022_08_01_preview.models.Dimension] + :ivar operator: The criteria operator. Relevant and required only for rules of the kind + LogAlert. Known values are: "Equals", "GreaterThan", "GreaterThanOrEqual", "LessThan", and + "LessThanOrEqual". + :vartype operator: str or + ~$(python-base-namespace).v2022_08_01_preview.models.ConditionOperator + :ivar threshold: the criteria threshold value that activates the alert. Relevant and required + only for rules of the kind LogAlert. + :vartype threshold: float + :ivar failing_periods: The minimum number of violations required within the selected lookback + time window required to raise an alert. Relevant only for rules of the kind LogAlert. + :vartype failing_periods: + ~$(python-base-namespace).v2022_08_01_preview.models.ConditionFailingPeriods + :ivar metric_name: The name of the metric to be sent. Relevant and required only for rules of + the kind LogToMetric. + :vartype metric_name: str + """ + + _attribute_map = { + "query": {"key": "query", "type": "str"}, + "time_aggregation": {"key": "timeAggregation", "type": "str"}, + "metric_measure_column": {"key": "metricMeasureColumn", "type": "str"}, + "resource_id_column": {"key": "resourceIdColumn", "type": "str"}, + "dimensions": {"key": "dimensions", "type": "[Dimension]"}, + "operator": {"key": "operator", "type": "str"}, + "threshold": {"key": "threshold", "type": "float"}, + "failing_periods": {"key": "failingPeriods", "type": "ConditionFailingPeriods"}, + "metric_name": {"key": "metricName", "type": "str"}, + } + + def __init__( + self, + *, + query: Optional[str] = None, + time_aggregation: Optional[Union[str, "_models.TimeAggregation"]] = None, + metric_measure_column: Optional[str] = None, + resource_id_column: Optional[str] = None, + dimensions: Optional[List["_models.Dimension"]] = None, + operator: Optional[Union[str, "_models.ConditionOperator"]] = None, + threshold: Optional[float] = None, + failing_periods: Optional["_models.ConditionFailingPeriods"] = None, + metric_name: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword query: Log query alert. + :paramtype query: str + :keyword time_aggregation: Aggregation type. Relevant and required only for rules of the kind + LogAlert. Known values are: "Count", "Average", "Minimum", "Maximum", and "Total". + :paramtype time_aggregation: str or + ~$(python-base-namespace).v2022_08_01_preview.models.TimeAggregation + :keyword metric_measure_column: The column containing the metric measure number. Relevant only + for rules of the kind LogAlert. + :paramtype metric_measure_column: str + :keyword resource_id_column: The column containing the resource id. The content of the column + must be a uri formatted as resource id. Relevant only for rules of the kind LogAlert. + :paramtype resource_id_column: str + :keyword dimensions: List of Dimensions conditions. + :paramtype dimensions: list[~$(python-base-namespace).v2022_08_01_preview.models.Dimension] + :keyword operator: The criteria operator. Relevant and required only for rules of the kind + LogAlert. Known values are: "Equals", "GreaterThan", "GreaterThanOrEqual", "LessThan", and + "LessThanOrEqual". + :paramtype operator: str or + ~$(python-base-namespace).v2022_08_01_preview.models.ConditionOperator + :keyword threshold: the criteria threshold value that activates the alert. Relevant and + required only for rules of the kind LogAlert. + :paramtype threshold: float + :keyword failing_periods: The minimum number of violations required within the selected + lookback time window required to raise an alert. Relevant only for rules of the kind LogAlert. + :paramtype failing_periods: + ~$(python-base-namespace).v2022_08_01_preview.models.ConditionFailingPeriods + :keyword metric_name: The name of the metric to be sent. Relevant and required only for rules + of the kind LogToMetric. + :paramtype metric_name: str + """ + super().__init__(**kwargs) + self.query = query + self.time_aggregation = time_aggregation + self.metric_measure_column = metric_measure_column + self.resource_id_column = resource_id_column + self.dimensions = dimensions + self.operator = operator + self.threshold = threshold + self.failing_periods = failing_periods + self.metric_name = metric_name + + +class ConditionFailingPeriods(_serialization.Model): + """The minimum number of violations required within the selected lookback time window required to + raise an alert. Relevant only for rules of the kind LogAlert. + + :ivar number_of_evaluation_periods: The number of aggregated lookback points. The lookback time + window is calculated based on the aggregation granularity (windowSize) and the selected number + of aggregated points. Default value is 1. + :vartype number_of_evaluation_periods: int + :ivar min_failing_periods_to_alert: The number of violations to trigger an alert. Should be + smaller or equal to numberOfEvaluationPeriods. Default value is 1. + :vartype min_failing_periods_to_alert: int + """ + + _attribute_map = { + "number_of_evaluation_periods": {"key": "numberOfEvaluationPeriods", "type": "int"}, + "min_failing_periods_to_alert": {"key": "minFailingPeriodsToAlert", "type": "int"}, + } + + def __init__( + self, *, number_of_evaluation_periods: int = 1, min_failing_periods_to_alert: int = 1, **kwargs: Any + ) -> None: + """ + :keyword number_of_evaluation_periods: The number of aggregated lookback points. The lookback + time window is calculated based on the aggregation granularity (windowSize) and the selected + number of aggregated points. Default value is 1. + :paramtype number_of_evaluation_periods: int + :keyword min_failing_periods_to_alert: The number of violations to trigger an alert. Should be + smaller or equal to numberOfEvaluationPeriods. Default value is 1. + :paramtype min_failing_periods_to_alert: int + """ + super().__init__(**kwargs) + self.number_of_evaluation_periods = number_of_evaluation_periods + self.min_failing_periods_to_alert = min_failing_periods_to_alert + + +class Dimension(_serialization.Model): + """Dimension splitting and filtering definition. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Name of the dimension. Required. + :vartype name: str + :ivar operator: Operator for dimension values. Required. Known values are: "Include" and + "Exclude". + :vartype operator: str or + ~$(python-base-namespace).v2022_08_01_preview.models.DimensionOperator + :ivar values: List of dimension values. Required. + :vartype values: list[str] + """ + + _validation = { + "name": {"required": True}, + "operator": {"required": True}, + "values": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "operator": {"key": "operator", "type": "str"}, + "values": {"key": "values", "type": "[str]"}, + } + + def __init__( + self, *, name: str, operator: Union[str, "_models.DimensionOperator"], values: List[str], **kwargs: Any + ) -> None: + """ + :keyword name: Name of the dimension. Required. + :paramtype name: str + :keyword operator: Operator for dimension values. Required. Known values are: "Include" and + "Exclude". + :paramtype operator: str or + ~$(python-base-namespace).v2022_08_01_preview.models.DimensionOperator + :keyword values: List of dimension values. Required. + :paramtype values: list[str] + """ + super().__init__(**kwargs) + self.name = name + self.operator = operator + self.values = values + + +class ErrorContract(_serialization.Model): + """Describes the format of Error response. + + :ivar error: The error details. + :vartype error: ~$(python-base-namespace).v2022_08_01_preview.models.ErrorResponseDetails + """ + + _attribute_map = { + "error": {"key": "error", "type": "ErrorResponseDetails"}, + } + + def __init__(self, *, error: Optional["_models.ErrorResponseDetails"] = None, **kwargs: Any) -> None: + """ + :keyword error: The error details. + :paramtype error: ~$(python-base-namespace).v2022_08_01_preview.models.ErrorResponseDetails + """ + super().__init__(**kwargs) + self.error = error + + +class ErrorResponseAdditionalInfo(_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 ErrorResponseDetails(_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.). + + 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[~$(python-base-namespace).v2022_08_01_preview.models.ErrorResponseDetails] + :ivar additional_info: The error additional info. + :vartype additional_info: + list[~$(python-base-namespace).v2022_08_01_preview.models.ErrorResponseAdditionalInfo] + """ + + _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": "[ErrorResponseDetails]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorResponseAdditionalInfo]"}, + } + + 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 Identity(_serialization.Model): + """Identity for the resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar principal_id: The principal ID of resource identity. + :vartype principal_id: str + :ivar tenant_id: The tenant ID of resource. + :vartype tenant_id: str + :ivar type: Type of managed service identity. Required. Known values are: "SystemAssigned", + "UserAssigned", and "None". + :vartype type: str or ~$(python-base-namespace).v2022_08_01_preview.models.IdentityType + :ivar user_assigned_identities: The list of user identities associated with the resource. The + user identity dictionary key references will be ARM resource ids in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + :vartype user_assigned_identities: dict[str, + ~$(python-base-namespace).v2022_08_01_preview.models.UserIdentityProperties] + """ + + _validation = { + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, + "type": {"required": True}, + } + + _attribute_map = { + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserIdentityProperties}"}, + } + + def __init__( + self, + *, + type: Union[str, "_models.IdentityType"], + user_assigned_identities: Optional[Dict[str, "_models.UserIdentityProperties"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword type: Type of managed service identity. Required. Known values are: "SystemAssigned", + "UserAssigned", and "None". + :paramtype type: str or ~$(python-base-namespace).v2022_08_01_preview.models.IdentityType + :keyword user_assigned_identities: The list of user identities associated with the resource. + The user identity dictionary key references will be ARM resource ids in the form: + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + :paramtype user_assigned_identities: dict[str, + ~$(python-base-namespace).v2022_08_01_preview.models.UserIdentityProperties] + """ + super().__init__(**kwargs) + self.principal_id = None + self.tenant_id = None + self.type = type + self.user_assigned_identities = user_assigned_identities + + +class RuleResolveConfiguration(_serialization.Model): + """TBD. Relevant only for rules of the kind LogAlert. + + :ivar auto_resolved: The flag that indicates whether or not to auto resolve a fired alert. + :vartype auto_resolved: bool + :ivar time_to_resolve: The duration a rule must evaluate as healthy before the fired alert is + automatically resolved represented in ISO 8601 duration format. + :vartype time_to_resolve: ~datetime.timedelta + """ + + _attribute_map = { + "auto_resolved": {"key": "autoResolved", "type": "bool"}, + "time_to_resolve": {"key": "timeToResolve", "type": "duration"}, + } + + def __init__( + self, + *, + auto_resolved: Optional[bool] = None, + time_to_resolve: Optional[datetime.timedelta] = None, + **kwargs: Any + ) -> None: + """ + :keyword auto_resolved: The flag that indicates whether or not to auto resolve a fired alert. + :paramtype auto_resolved: bool + :keyword time_to_resolve: The duration a rule must evaluate as healthy before the fired alert + is automatically resolved represented in ISO 8601 duration format. + :paramtype time_to_resolve: ~datetime.timedelta + """ + super().__init__(**kwargs) + self.auto_resolved = auto_resolved + self.time_to_resolve = time_to_resolve + + +class ScheduledQueryRuleCriteria(_serialization.Model): + """The rule criteria that defines the conditions of the scheduled query rule. + + :ivar all_of: A list of conditions to evaluate against the specified scopes. + :vartype all_of: list[~$(python-base-namespace).v2022_08_01_preview.models.Condition] + """ + + _attribute_map = { + "all_of": {"key": "allOf", "type": "[Condition]"}, + } + + def __init__(self, *, all_of: Optional[List["_models.Condition"]] = None, **kwargs: Any) -> None: + """ + :keyword all_of: A list of conditions to evaluate against the specified scopes. + :paramtype all_of: list[~$(python-base-namespace).v2022_08_01_preview.models.Condition] + """ + super().__init__(**kwargs) + self.all_of = all_of + + +class ScheduledQueryRuleResource(_serialization.Model): # pylint: disable=too-many-instance-attributes + """The scheduled query rule resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: 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 identity: The identity of the resource. + :vartype identity: ~$(python-base-namespace).v2022_08_01_preview.models.Identity + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar kind: Indicates the type of scheduled query rule. The default is LogAlert. Known values + are: "LogAlert" and "LogToMetric". + :vartype kind: str or ~$(python-base-namespace).v2022_08_01_preview.models.Kind + :ivar etag: The etag field is *not* required. If it is provided in the response body, it must + also be provided as a header per the normal etag convention. Entity tags are used for + comparing two or more entities from the same requested resource. HTTP/1.1 uses entity tags in + the etag (section 14.19), If-Match (section 14.24), If-None-Match (section 14.26), and If-Range + (section 14.27) header fields. + :vartype etag: str + :ivar system_data: SystemData of ScheduledQueryRule. + :vartype system_data: ~$(python-base-namespace).v2022_08_01_preview.models.SystemData + :ivar created_with_api_version: The api-version used when creating this alert rule. + :vartype created_with_api_version: str + :ivar is_legacy_log_analytics_rule: True if alert rule is legacy Log Analytic rule. + :vartype is_legacy_log_analytics_rule: bool + :ivar description: The description of the scheduled query rule. + :vartype description: str + :ivar display_name: The display name of the alert rule. + :vartype display_name: str + :ivar severity: Severity of the alert. Should be an integer between [0-4]. Value of 0 is + severest. Relevant and required only for rules of the kind LogAlert. Known values are: 0, 1, 2, + 3, and 4. + :vartype severity: int or ~$(python-base-namespace).v2022_08_01_preview.models.AlertSeverity + :ivar enabled: The flag which indicates whether this scheduled query rule is enabled. Value + should be true or false. + :vartype enabled: bool + :ivar public_network_access: This determines if traffic is allowed over public network. By + default it is enabled. Known values are: "Enabled", "Disabled", and "SecuredByPerimeter". + :vartype public_network_access: str or + ~$(python-base-namespace).v2022_08_01_preview.models.PublicNetworkAccess + :ivar scopes: The list of resource id's that this scheduled query rule is scoped to. + :vartype scopes: list[str] + :ivar evaluation_frequency: How often the scheduled query rule is evaluated represented in ISO + 8601 duration format. Relevant and required only for rules of the kind LogAlert. + :vartype evaluation_frequency: ~datetime.timedelta + :ivar window_size: The period of time (in ISO 8601 duration format) on which the Alert query + will be executed (bin size). Relevant and required only for rules of the kind LogAlert. + :vartype window_size: ~datetime.timedelta + :ivar override_query_time_range: If specified then overrides the query time range (default is + WindowSize*NumberOfEvaluationPeriods). Relevant only for rules of the kind LogAlert. + :vartype override_query_time_range: ~datetime.timedelta + :ivar target_resource_types: List of resource type of the target resource(s) on which the alert + is created/updated. For example if the scope is a resource group and targetResourceTypes is + Microsoft.Compute/virtualMachines, then a different alert will be fired for each virtual + machine in the resource group which meet the alert criteria. Relevant only for rules of the + kind LogAlert. + :vartype target_resource_types: list[str] + :ivar criteria: The rule criteria that defines the conditions of the scheduled query rule. + :vartype criteria: + ~$(python-base-namespace).v2022_08_01_preview.models.ScheduledQueryRuleCriteria + :ivar mute_actions_duration: Mute actions for the chosen period of time (in ISO 8601 duration + format) after the alert is fired. Relevant only for rules of the kind LogAlert. + :vartype mute_actions_duration: ~datetime.timedelta + :ivar actions: Actions to invoke when the alert fires. + :vartype actions: ~$(python-base-namespace).v2022_08_01_preview.models.Actions + :ivar is_workspace_alerts_storage_configured: The flag which indicates whether this scheduled + query rule has been configured to be stored in the customer's storage. The default is false. + :vartype is_workspace_alerts_storage_configured: bool + :ivar check_workspace_alerts_storage_configured: The flag which indicates whether this + scheduled query rule should be stored in the customer's storage. The default is false. Relevant + only for rules of the kind LogAlert. + :vartype check_workspace_alerts_storage_configured: bool + :ivar skip_query_validation: The flag which indicates whether the provided query should be + validated or not. The default is false. Relevant only for rules of the kind LogAlert. + :vartype skip_query_validation: bool + :ivar auto_mitigate: The flag that indicates whether the alert should be automatically resolved + or not. The default is true. Relevant only for rules of the kind LogAlert. + :vartype auto_mitigate: bool + :ivar rule_resolve_configuration: Defines the configuration for resolving fired alerts. + Relevant only for rules of the kind LogAlert. + :vartype rule_resolve_configuration: + ~$(python-base-namespace).v2022_08_01_preview.models.RuleResolveConfiguration + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "etag": {"readonly": True}, + "system_data": {"readonly": True}, + "created_with_api_version": {"readonly": True}, + "is_legacy_log_analytics_rule": {"readonly": True}, + "is_workspace_alerts_storage_configured": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "identity": {"key": "identity", "type": "Identity"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "created_with_api_version": {"key": "properties.createdWithApiVersion", "type": "str"}, + "is_legacy_log_analytics_rule": {"key": "properties.isLegacyLogAnalyticsRule", "type": "bool"}, + "description": {"key": "properties.description", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "severity": {"key": "properties.severity", "type": "int"}, + "enabled": {"key": "properties.enabled", "type": "bool"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "scopes": {"key": "properties.scopes", "type": "[str]"}, + "evaluation_frequency": {"key": "properties.evaluationFrequency", "type": "duration"}, + "window_size": {"key": "properties.windowSize", "type": "duration"}, + "override_query_time_range": {"key": "properties.overrideQueryTimeRange", "type": "duration"}, + "target_resource_types": {"key": "properties.targetResourceTypes", "type": "[str]"}, + "criteria": {"key": "properties.criteria", "type": "ScheduledQueryRuleCriteria"}, + "mute_actions_duration": {"key": "properties.muteActionsDuration", "type": "duration"}, + "actions": {"key": "properties.actions", "type": "Actions"}, + "is_workspace_alerts_storage_configured": { + "key": "properties.isWorkspaceAlertsStorageConfigured", + "type": "bool", + }, + "check_workspace_alerts_storage_configured": { + "key": "properties.checkWorkspaceAlertsStorageConfigured", + "type": "bool", + }, + "skip_query_validation": {"key": "properties.skipQueryValidation", "type": "bool"}, + "auto_mitigate": {"key": "properties.autoMitigate", "type": "bool"}, + "rule_resolve_configuration": { + "key": "properties.ruleResolveConfiguration", + "type": "RuleResolveConfiguration", + }, + } + + def __init__( # pylint: disable=too-many-locals + self, + *, + location: str, + identity: Optional["_models.Identity"] = None, + tags: Optional[Dict[str, str]] = None, + kind: Optional[Union[str, "_models.Kind"]] = None, + description: Optional[str] = None, + display_name: Optional[str] = None, + severity: Optional[Union[int, "_models.AlertSeverity"]] = None, + enabled: Optional[bool] = None, + public_network_access: Union[str, "_models.PublicNetworkAccess"] = "Enabled", + scopes: Optional[List[str]] = None, + evaluation_frequency: Optional[datetime.timedelta] = None, + window_size: Optional[datetime.timedelta] = None, + override_query_time_range: Optional[datetime.timedelta] = None, + target_resource_types: Optional[List[str]] = None, + criteria: Optional["_models.ScheduledQueryRuleCriteria"] = None, + mute_actions_duration: Optional[datetime.timedelta] = None, + actions: Optional["_models.Actions"] = None, + check_workspace_alerts_storage_configured: Optional[bool] = None, + skip_query_validation: Optional[bool] = None, + auto_mitigate: Optional[bool] = None, + rule_resolve_configuration: Optional["_models.RuleResolveConfiguration"] = None, + **kwargs: Any + ) -> None: + """ + :keyword identity: The identity of the resource. + :paramtype identity: ~$(python-base-namespace).v2022_08_01_preview.models.Identity + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + :keyword kind: Indicates the type of scheduled query rule. The default is LogAlert. Known + values are: "LogAlert" and "LogToMetric". + :paramtype kind: str or ~$(python-base-namespace).v2022_08_01_preview.models.Kind + :keyword description: The description of the scheduled query rule. + :paramtype description: str + :keyword display_name: The display name of the alert rule. + :paramtype display_name: str + :keyword severity: Severity of the alert. Should be an integer between [0-4]. Value of 0 is + severest. Relevant and required only for rules of the kind LogAlert. Known values are: 0, 1, 2, + 3, and 4. + :paramtype severity: int or ~$(python-base-namespace).v2022_08_01_preview.models.AlertSeverity + :keyword enabled: The flag which indicates whether this scheduled query rule is enabled. Value + should be true or false. + :paramtype enabled: bool + :keyword public_network_access: This determines if traffic is allowed over public network. By + default it is enabled. Known values are: "Enabled", "Disabled", and "SecuredByPerimeter". + :paramtype public_network_access: str or + ~$(python-base-namespace).v2022_08_01_preview.models.PublicNetworkAccess + :keyword scopes: The list of resource id's that this scheduled query rule is scoped to. + :paramtype scopes: list[str] + :keyword evaluation_frequency: How often the scheduled query rule is evaluated represented in + ISO 8601 duration format. Relevant and required only for rules of the kind LogAlert. + :paramtype evaluation_frequency: ~datetime.timedelta + :keyword window_size: The period of time (in ISO 8601 duration format) on which the Alert query + will be executed (bin size). Relevant and required only for rules of the kind LogAlert. + :paramtype window_size: ~datetime.timedelta + :keyword override_query_time_range: If specified then overrides the query time range (default + is WindowSize*NumberOfEvaluationPeriods). Relevant only for rules of the kind LogAlert. + :paramtype override_query_time_range: ~datetime.timedelta + :keyword target_resource_types: List of resource type of the target resource(s) on which the + alert is created/updated. For example if the scope is a resource group and targetResourceTypes + is Microsoft.Compute/virtualMachines, then a different alert will be fired for each virtual + machine in the resource group which meet the alert criteria. Relevant only for rules of the + kind LogAlert. + :paramtype target_resource_types: list[str] + :keyword criteria: The rule criteria that defines the conditions of the scheduled query rule. + :paramtype criteria: + ~$(python-base-namespace).v2022_08_01_preview.models.ScheduledQueryRuleCriteria + :keyword mute_actions_duration: Mute actions for the chosen period of time (in ISO 8601 + duration format) after the alert is fired. Relevant only for rules of the kind LogAlert. + :paramtype mute_actions_duration: ~datetime.timedelta + :keyword actions: Actions to invoke when the alert fires. + :paramtype actions: ~$(python-base-namespace).v2022_08_01_preview.models.Actions + :keyword check_workspace_alerts_storage_configured: The flag which indicates whether this + scheduled query rule should be stored in the customer's storage. The default is false. Relevant + only for rules of the kind LogAlert. + :paramtype check_workspace_alerts_storage_configured: bool + :keyword skip_query_validation: The flag which indicates whether the provided query should be + validated or not. The default is false. Relevant only for rules of the kind LogAlert. + :paramtype skip_query_validation: bool + :keyword auto_mitigate: The flag that indicates whether the alert should be automatically + resolved or not. The default is true. Relevant only for rules of the kind LogAlert. + :paramtype auto_mitigate: bool + :keyword rule_resolve_configuration: Defines the configuration for resolving fired alerts. + Relevant only for rules of the kind LogAlert. + :paramtype rule_resolve_configuration: + ~$(python-base-namespace).v2022_08_01_preview.models.RuleResolveConfiguration + """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.identity = identity + self.tags = tags + self.location = location + self.kind = kind + self.etag = None + self.system_data = None + self.created_with_api_version = None + self.is_legacy_log_analytics_rule = None + self.description = description + self.display_name = display_name + self.severity = severity + self.enabled = enabled + self.public_network_access = public_network_access + self.scopes = scopes + self.evaluation_frequency = evaluation_frequency + self.window_size = window_size + self.override_query_time_range = override_query_time_range + self.target_resource_types = target_resource_types + self.criteria = criteria + self.mute_actions_duration = mute_actions_duration + self.actions = actions + self.is_workspace_alerts_storage_configured = None + self.check_workspace_alerts_storage_configured = check_workspace_alerts_storage_configured + self.skip_query_validation = skip_query_validation + self.auto_mitigate = auto_mitigate + self.rule_resolve_configuration = rule_resolve_configuration + + +class ScheduledQueryRuleResourceCollection(_serialization.Model): + """Represents a collection of scheduled query rule resources. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The values for the scheduled query rule resources. + :vartype value: + list[~$(python-base-namespace).v2022_08_01_preview.models.ScheduledQueryRuleResource] + :ivar next_link: Provides the link to retrieve the next set of elements. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[ScheduledQueryRuleResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.ScheduledQueryRuleResource"]] = None, **kwargs: Any) -> None: + """ + :keyword value: The values for the scheduled query rule resources. + :paramtype value: + list[~$(python-base-namespace).v2022_08_01_preview.models.ScheduledQueryRuleResource] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class ScheduledQueryRuleResourcePatch(_serialization.Model): # pylint: disable=too-many-instance-attributes + """The scheduled query rule resource for patch operations. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar identity: The identity of the resource. + :vartype identity: ~$(python-base-namespace).v2022_08_01_preview.models.Identity + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar created_with_api_version: The api-version used when creating this alert rule. + :vartype created_with_api_version: str + :ivar is_legacy_log_analytics_rule: True if alert rule is legacy Log Analytic rule. + :vartype is_legacy_log_analytics_rule: bool + :ivar description: The description of the scheduled query rule. + :vartype description: str + :ivar display_name: The display name of the alert rule. + :vartype display_name: str + :ivar severity: Severity of the alert. Should be an integer between [0-4]. Value of 0 is + severest. Relevant and required only for rules of the kind LogAlert. Known values are: 0, 1, 2, + 3, and 4. + :vartype severity: int or ~$(python-base-namespace).v2022_08_01_preview.models.AlertSeverity + :ivar enabled: The flag which indicates whether this scheduled query rule is enabled. Value + should be true or false. + :vartype enabled: bool + :ivar public_network_access: This determines if traffic is allowed over public network. By + default it is enabled. Known values are: "Enabled", "Disabled", and "SecuredByPerimeter". + :vartype public_network_access: str or + ~$(python-base-namespace).v2022_08_01_preview.models.PublicNetworkAccess + :ivar scopes: The list of resource id's that this scheduled query rule is scoped to. + :vartype scopes: list[str] + :ivar evaluation_frequency: How often the scheduled query rule is evaluated represented in ISO + 8601 duration format. Relevant and required only for rules of the kind LogAlert. + :vartype evaluation_frequency: ~datetime.timedelta + :ivar window_size: The period of time (in ISO 8601 duration format) on which the Alert query + will be executed (bin size). Relevant and required only for rules of the kind LogAlert. + :vartype window_size: ~datetime.timedelta + :ivar override_query_time_range: If specified then overrides the query time range (default is + WindowSize*NumberOfEvaluationPeriods). Relevant only for rules of the kind LogAlert. + :vartype override_query_time_range: ~datetime.timedelta + :ivar target_resource_types: List of resource type of the target resource(s) on which the alert + is created/updated. For example if the scope is a resource group and targetResourceTypes is + Microsoft.Compute/virtualMachines, then a different alert will be fired for each virtual + machine in the resource group which meet the alert criteria. Relevant only for rules of the + kind LogAlert. + :vartype target_resource_types: list[str] + :ivar criteria: The rule criteria that defines the conditions of the scheduled query rule. + :vartype criteria: + ~$(python-base-namespace).v2022_08_01_preview.models.ScheduledQueryRuleCriteria + :ivar mute_actions_duration: Mute actions for the chosen period of time (in ISO 8601 duration + format) after the alert is fired. Relevant only for rules of the kind LogAlert. + :vartype mute_actions_duration: ~datetime.timedelta + :ivar actions: Actions to invoke when the alert fires. + :vartype actions: ~$(python-base-namespace).v2022_08_01_preview.models.Actions + :ivar is_workspace_alerts_storage_configured: The flag which indicates whether this scheduled + query rule has been configured to be stored in the customer's storage. The default is false. + :vartype is_workspace_alerts_storage_configured: bool + :ivar check_workspace_alerts_storage_configured: The flag which indicates whether this + scheduled query rule should be stored in the customer's storage. The default is false. Relevant + only for rules of the kind LogAlert. + :vartype check_workspace_alerts_storage_configured: bool + :ivar skip_query_validation: The flag which indicates whether the provided query should be + validated or not. The default is false. Relevant only for rules of the kind LogAlert. + :vartype skip_query_validation: bool + :ivar auto_mitigate: The flag that indicates whether the alert should be automatically resolved + or not. The default is true. Relevant only for rules of the kind LogAlert. + :vartype auto_mitigate: bool + :ivar rule_resolve_configuration: Defines the configuration for resolving fired alerts. + Relevant only for rules of the kind LogAlert. + :vartype rule_resolve_configuration: + ~$(python-base-namespace).v2022_08_01_preview.models.RuleResolveConfiguration + """ + + _validation = { + "created_with_api_version": {"readonly": True}, + "is_legacy_log_analytics_rule": {"readonly": True}, + "is_workspace_alerts_storage_configured": {"readonly": True}, + } + + _attribute_map = { + "identity": {"key": "identity", "type": "Identity"}, + "tags": {"key": "tags", "type": "{str}"}, + "created_with_api_version": {"key": "properties.createdWithApiVersion", "type": "str"}, + "is_legacy_log_analytics_rule": {"key": "properties.isLegacyLogAnalyticsRule", "type": "bool"}, + "description": {"key": "properties.description", "type": "str"}, + "display_name": {"key": "properties.displayName", "type": "str"}, + "severity": {"key": "properties.severity", "type": "int"}, + "enabled": {"key": "properties.enabled", "type": "bool"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "scopes": {"key": "properties.scopes", "type": "[str]"}, + "evaluation_frequency": {"key": "properties.evaluationFrequency", "type": "duration"}, + "window_size": {"key": "properties.windowSize", "type": "duration"}, + "override_query_time_range": {"key": "properties.overrideQueryTimeRange", "type": "duration"}, + "target_resource_types": {"key": "properties.targetResourceTypes", "type": "[str]"}, + "criteria": {"key": "properties.criteria", "type": "ScheduledQueryRuleCriteria"}, + "mute_actions_duration": {"key": "properties.muteActionsDuration", "type": "duration"}, + "actions": {"key": "properties.actions", "type": "Actions"}, + "is_workspace_alerts_storage_configured": { + "key": "properties.isWorkspaceAlertsStorageConfigured", + "type": "bool", + }, + "check_workspace_alerts_storage_configured": { + "key": "properties.checkWorkspaceAlertsStorageConfigured", + "type": "bool", + }, + "skip_query_validation": {"key": "properties.skipQueryValidation", "type": "bool"}, + "auto_mitigate": {"key": "properties.autoMitigate", "type": "bool"}, + "rule_resolve_configuration": { + "key": "properties.ruleResolveConfiguration", + "type": "RuleResolveConfiguration", + }, + } + + def __init__( + self, + *, + identity: Optional["_models.Identity"] = None, + tags: Optional[Dict[str, str]] = None, + description: Optional[str] = None, + display_name: Optional[str] = None, + severity: Optional[Union[int, "_models.AlertSeverity"]] = None, + enabled: Optional[bool] = None, + public_network_access: Union[str, "_models.PublicNetworkAccess"] = "Enabled", + scopes: Optional[List[str]] = None, + evaluation_frequency: Optional[datetime.timedelta] = None, + window_size: Optional[datetime.timedelta] = None, + override_query_time_range: Optional[datetime.timedelta] = None, + target_resource_types: Optional[List[str]] = None, + criteria: Optional["_models.ScheduledQueryRuleCriteria"] = None, + mute_actions_duration: Optional[datetime.timedelta] = None, + actions: Optional["_models.Actions"] = None, + check_workspace_alerts_storage_configured: Optional[bool] = None, + skip_query_validation: Optional[bool] = None, + auto_mitigate: Optional[bool] = None, + rule_resolve_configuration: Optional["_models.RuleResolveConfiguration"] = None, + **kwargs: Any + ) -> None: + """ + :keyword identity: The identity of the resource. + :paramtype identity: ~$(python-base-namespace).v2022_08_01_preview.models.Identity + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword description: The description of the scheduled query rule. + :paramtype description: str + :keyword display_name: The display name of the alert rule. + :paramtype display_name: str + :keyword severity: Severity of the alert. Should be an integer between [0-4]. Value of 0 is + severest. Relevant and required only for rules of the kind LogAlert. Known values are: 0, 1, 2, + 3, and 4. + :paramtype severity: int or ~$(python-base-namespace).v2022_08_01_preview.models.AlertSeverity + :keyword enabled: The flag which indicates whether this scheduled query rule is enabled. Value + should be true or false. + :paramtype enabled: bool + :keyword public_network_access: This determines if traffic is allowed over public network. By + default it is enabled. Known values are: "Enabled", "Disabled", and "SecuredByPerimeter". + :paramtype public_network_access: str or + ~$(python-base-namespace).v2022_08_01_preview.models.PublicNetworkAccess + :keyword scopes: The list of resource id's that this scheduled query rule is scoped to. + :paramtype scopes: list[str] + :keyword evaluation_frequency: How often the scheduled query rule is evaluated represented in + ISO 8601 duration format. Relevant and required only for rules of the kind LogAlert. + :paramtype evaluation_frequency: ~datetime.timedelta + :keyword window_size: The period of time (in ISO 8601 duration format) on which the Alert query + will be executed (bin size). Relevant and required only for rules of the kind LogAlert. + :paramtype window_size: ~datetime.timedelta + :keyword override_query_time_range: If specified then overrides the query time range (default + is WindowSize*NumberOfEvaluationPeriods). Relevant only for rules of the kind LogAlert. + :paramtype override_query_time_range: ~datetime.timedelta + :keyword target_resource_types: List of resource type of the target resource(s) on which the + alert is created/updated. For example if the scope is a resource group and targetResourceTypes + is Microsoft.Compute/virtualMachines, then a different alert will be fired for each virtual + machine in the resource group which meet the alert criteria. Relevant only for rules of the + kind LogAlert. + :paramtype target_resource_types: list[str] + :keyword criteria: The rule criteria that defines the conditions of the scheduled query rule. + :paramtype criteria: + ~$(python-base-namespace).v2022_08_01_preview.models.ScheduledQueryRuleCriteria + :keyword mute_actions_duration: Mute actions for the chosen period of time (in ISO 8601 + duration format) after the alert is fired. Relevant only for rules of the kind LogAlert. + :paramtype mute_actions_duration: ~datetime.timedelta + :keyword actions: Actions to invoke when the alert fires. + :paramtype actions: ~$(python-base-namespace).v2022_08_01_preview.models.Actions + :keyword check_workspace_alerts_storage_configured: The flag which indicates whether this + scheduled query rule should be stored in the customer's storage. The default is false. Relevant + only for rules of the kind LogAlert. + :paramtype check_workspace_alerts_storage_configured: bool + :keyword skip_query_validation: The flag which indicates whether the provided query should be + validated or not. The default is false. Relevant only for rules of the kind LogAlert. + :paramtype skip_query_validation: bool + :keyword auto_mitigate: The flag that indicates whether the alert should be automatically + resolved or not. The default is true. Relevant only for rules of the kind LogAlert. + :paramtype auto_mitigate: bool + :keyword rule_resolve_configuration: Defines the configuration for resolving fired alerts. + Relevant only for rules of the kind LogAlert. + :paramtype rule_resolve_configuration: + ~$(python-base-namespace).v2022_08_01_preview.models.RuleResolveConfiguration + """ + super().__init__(**kwargs) + self.identity = identity + self.tags = tags + self.created_with_api_version = None + self.is_legacy_log_analytics_rule = None + self.description = description + self.display_name = display_name + self.severity = severity + self.enabled = enabled + self.public_network_access = public_network_access + self.scopes = scopes + self.evaluation_frequency = evaluation_frequency + self.window_size = window_size + self.override_query_time_range = override_query_time_range + self.target_resource_types = target_resource_types + self.criteria = criteria + self.mute_actions_duration = mute_actions_duration + self.actions = actions + self.is_workspace_alerts_storage_configured = None + self.check_workspace_alerts_storage_configured = check_workspace_alerts_storage_configured + self.skip_query_validation = skip_query_validation + self.auto_mitigate = auto_mitigate + self.rule_resolve_configuration = rule_resolve_configuration + + +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 + ~$(python-base-namespace).v2022_08_01_preview.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". + :vartype last_modified_by_type: str or + ~$(python-base-namespace).v2022_08_01_preview.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + "created_by": {"key": "createdBy", "type": "str"}, + "created_by_type": {"key": "createdByType", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, + "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs: 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 + ~$(python-base-namespace).v2022_08_01_preview.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". + :paramtype last_modified_by_type: str or + ~$(python-base-namespace).v2022_08_01_preview.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ + super().__init__(**kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at + + +class UserIdentityProperties(_serialization.Model): + """User assigned identity properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal id of user assigned identity. + :vartype principal_id: str + :ivar client_id: The client id of user assigned identity. + :vartype client_id: str + """ + + _validation = { + "principal_id": {"readonly": True}, + "client_id": {"readonly": True}, + } + + _attribute_map = { + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.principal_id = None + self.client_id = None diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/models/_monitor_management_client_enums.py new file mode 100644 index 000000000000..087b33ff7efe --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/models/_monitor_management_client_enums.py @@ -0,0 +1,81 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class AlertSeverity(int, Enum, metaclass=CaseInsensitiveEnumMeta): + """Severity of the alert. Should be an integer between [0-4]. Value of 0 is severest. Relevant and + required only for rules of the kind LogAlert. + """ + + ZERO = 0 + ONE = 1 + TWO = 2 + THREE = 3 + FOUR = 4 + + +class ConditionOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The criteria operator. Relevant and required only for rules of the kind LogAlert.""" + + EQUALS = "Equals" + GREATER_THAN = "GreaterThan" + GREATER_THAN_OR_EQUAL = "GreaterThanOrEqual" + LESS_THAN = "LessThan" + LESS_THAN_OR_EQUAL = "LessThanOrEqual" + + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + + +class DimensionOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Operator for dimension values.""" + + INCLUDE = "Include" + EXCLUDE = "Exclude" + + +class IdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of managed service identity.""" + + SYSTEM_ASSIGNED = "SystemAssigned" + USER_ASSIGNED = "UserAssigned" + NONE = "None" + + +class Kind(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates the type of scheduled query rule. The default is LogAlert.""" + + LOG_ALERT = "LogAlert" + LOG_TO_METRIC = "LogToMetric" + + +class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """This determines if traffic is allowed over public network. By default it is enabled.""" + + ENABLED = "Enabled" + DISABLED = "Disabled" + SECURED_BY_PERIMETER = "SecuredByPerimeter" + + +class TimeAggregation(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Aggregation type. Relevant and required only for rules of the kind LogAlert.""" + + COUNT = "Count" + AVERAGE = "Average" + MINIMUM = "Minimum" + MAXIMUM = "Maximum" + TOTAL = "Total" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/models/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/operations/__init__.py new file mode 100644 index 000000000000..e010c281d4fc --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/operations/__init__.py @@ -0,0 +1,19 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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 ._scheduled_query_rules_operations import ScheduledQueryRulesOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "ScheduledQueryRulesOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/operations/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/operations/_scheduled_query_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/operations/_scheduled_query_rules_operations.py new file mode 100644 index 000000000000..babdf5d2b57d --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/operations/_scheduled_query_rules_operations.py @@ -0,0 +1,861 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_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: Literal["2022-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/scheduledQueryRules" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules", + ) # 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 = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}", + ) # 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 + ), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}", + ) # 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 + ), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request(resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}", + ) # 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 + ), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request(resource_group_name: str, rule_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}", + ) # 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 + ), + "ruleName": _SERIALIZER.url("rule_name", rule_name, "str"), + } + + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class ScheduledQueryRulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~$(python-base-namespace).v2022_08_01_preview.MonitorManagementClient`'s + :attr:`scheduled_query_rules` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.ScheduledQueryRuleResource"]: + """Retrieve a scheduled query rule definitions in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ScheduledQueryRuleResource or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2022_08_01_preview.models.ScheduledQueryRuleResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) + cls: ClsType[_models.ScheduledQueryRuleResourceCollection] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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("ScheduledQueryRuleResourceCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/scheduledQueryRules" + } + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.ScheduledQueryRuleResource"]: + """Retrieve scheduled query rule definitions 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 + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ScheduledQueryRuleResource or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2022_08_01_preview.models.ScheduledQueryRuleResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) + cls: ClsType[_models.ScheduledQueryRuleResourceCollection] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ScheduledQueryRuleResourceCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules" + } + + @distributed_trace + def get(self, resource_group_name: str, rule_name: str, **kwargs: Any) -> _models.ScheduledQueryRuleResource: + """Retrieve an scheduled query rule definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ScheduledQueryRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_08_01_preview.models.ScheduledQueryRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) + cls: ClsType[_models.ScheduledQueryRuleResource] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ScheduledQueryRuleResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}" + } + + @overload + def create_or_update( + self, + resource_group_name: str, + rule_name: str, + parameters: _models.ScheduledQueryRuleResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ScheduledQueryRuleResource: + """Creates or updates a scheduled query rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to create or update. Required. + :type parameters: + ~$(python-base-namespace).v2022_08_01_preview.models.ScheduledQueryRuleResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ScheduledQueryRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_08_01_preview.models.ScheduledQueryRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ScheduledQueryRuleResource: + """Creates or updates a scheduled query rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to create or update. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ScheduledQueryRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_08_01_preview.models.ScheduledQueryRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + rule_name: str, + parameters: Union[_models.ScheduledQueryRuleResource, IO], + **kwargs: Any + ) -> _models.ScheduledQueryRuleResource: + """Creates or updates a scheduled query rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to create or update. Is either a + ScheduledQueryRuleResource type or a IO type. Required. + :type parameters: + ~$(python-base-namespace).v2022_08_01_preview.models.ScheduledQueryRuleResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ScheduledQueryRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_08_01_preview.models.ScheduledQueryRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScheduledQueryRuleResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScheduledQueryRuleResource") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ScheduledQueryRuleResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ScheduledQueryRuleResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}" + } + + @overload + def update( + self, + resource_group_name: str, + rule_name: str, + parameters: _models.ScheduledQueryRuleResourcePatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ScheduledQueryRuleResource: + """Update a scheduled query rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to update. Required. + :type parameters: + ~$(python-base-namespace).v2022_08_01_preview.models.ScheduledQueryRuleResourcePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ScheduledQueryRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_08_01_preview.models.ScheduledQueryRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + rule_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ScheduledQueryRuleResource: + """Update a scheduled query rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to update. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ScheduledQueryRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_08_01_preview.models.ScheduledQueryRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + rule_name: str, + parameters: Union[_models.ScheduledQueryRuleResourcePatch, IO], + **kwargs: Any + ) -> _models.ScheduledQueryRuleResource: + """Update a scheduled query rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :param parameters: The parameters of the rule to update. Is either a + ScheduledQueryRuleResourcePatch type or a IO type. Required. + :type parameters: + ~$(python-base-namespace).v2022_08_01_preview.models.ScheduledQueryRuleResourcePatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ScheduledQueryRuleResource or the result of cls(response) + :rtype: ~$(python-base-namespace).v2022_08_01_preview.models.ScheduledQueryRuleResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ScheduledQueryRuleResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ScheduledQueryRuleResourcePatch") + + request = build_update_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ScheduledQueryRuleResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}" + } + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, rule_name: str, **kwargs: Any + ) -> None: + """Deletes a scheduled query rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param rule_name: The name of the rule. Required. + :type rule_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: Literal["2022-08-01-preview"] = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/py.typed b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_08_01_preview/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/__init__.py index 8ba4823444a9..2c7733bfd566 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/__init__.py @@ -13,12 +13,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["MonitorManagementClient"] +__all__ = [ + "MonitorManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/_configuration.py index 8ca731670064..5b24348f04f9 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential @@ -36,7 +42,7 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2022-10-01") # type: str + api_version: Literal["2022-10-01"] = kwargs.pop("api_version", "2022-10-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -50,10 +56,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs kwargs.setdefault("sdk_moniker", "mgmt-monitor/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, **kwargs # type: Any - ): - # type: (...) -> None + def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/_metadata.json index e4abba12a71b..13f751ef148e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/_metadata.json @@ -19,13 +19,15 @@ "signature": "credential: \"TokenCredential\",", "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true + "required": true, + "method_location": "positional" }, "subscription_id": { "signature": "subscription_id: str,", "description": "The ID of the target subscription. Required.", "docstring_type": "str", - "required": true + "required": true, + "method_location": "positional" } }, "async": { @@ -48,22 +50,25 @@ "service_client_specific": { "sync": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "signature": "api_version: Optional[str]=None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles=KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } }, "async": { @@ -71,19 +76,22 @@ "signature": "api_version: Optional[str] = None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "base_url": { "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", - "required": false + "required": false, + "method_location": "positional" }, "profile": { "signature": "profile: KnownProfiles = KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", - "required": false + "required": false, + "method_location": "positional" } } } @@ -100,4 +108,4 @@ "autoscale_settings": "AutoscaleSettingsOperations", "predictive_metric": "PredictiveMetricOperations" } -} \ No newline at end of file +} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/_monitor_management_client.py index 9a12e4146d92..c86a99a2633a 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/_monitor_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from . import models +from . import models as _models from .._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import AutoscaleSettingsOperations, PredictiveMetricOperations @@ -54,7 +54,7 @@ def __init__( ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -87,15 +87,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> MonitorManagementClient + def __enter__(self) -> "MonitorManagementClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/_vendor.py index 9aad73fc743e..bd0df84f5319 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/_vendor.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/_vendor.py @@ -5,6 +5,8 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import List, cast + from azure.core.pipeline.transport import HttpRequest @@ -22,6 +24,7 @@ def _format_url_section(template, **kwargs): try: return template.format(**kwargs) except KeyError as key: - formatted_components = template.split("/") + # Need the cast, as for some reasons "split" is typed as list[str | Any] + formatted_components = cast(List[str], template.split("/")) components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/_version.py index ce9ac7ae37b3..e5754a47ce68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "5.0.1" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/aio/__init__.py index 8638dc69d869..2c151bb41c19 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/aio/__init__.py @@ -10,12 +10,14 @@ try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["MonitorManagementClient"] +__all__ = [ + "MonitorManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/aio/_configuration.py index c68825f79615..8539bfb83e81 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential @@ -36,7 +42,7 @@ class MonitorManagementClientConfiguration(Configuration): # pylint: disable=to def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(MonitorManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2022-10-01") # type: str + api_version: Literal["2022-10-01"] = kwargs.pop("api_version", "2022-10-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/aio/_monitor_management_client.py index 6b407c77fb5a..9e9e216966c4 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/aio/_monitor_management_client.py @@ -12,7 +12,7 @@ from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from .. import models +from .. import models as _models from ..._serialization import Deserializer, Serializer from ._configuration import MonitorManagementClientConfiguration from .operations import AutoscaleSettingsOperations, PredictiveMetricOperations @@ -54,7 +54,7 @@ def __init__( ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False @@ -94,5 +94,5 @@ async def __aenter__(self) -> "MonitorManagementClient": await self._client.__aenter__() return self - async def __aexit__(self, *exc_details) -> None: + async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/aio/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/aio/operations/__init__.py index f80e4dc72702..3d1ab289551f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/aio/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/aio/operations/__init__.py @@ -10,7 +10,7 @@ from ._predictive_metric_operations import PredictiveMetricOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/aio/operations/_autoscale_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/aio/operations/_autoscale_settings_operations.py index 4e35b1abd6bb..459bf9b34a5a 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/aio/operations/_autoscale_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/aio/operations/_autoscale_settings_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -37,6 +38,10 @@ build_update_request, ) +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -79,8 +84,8 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.AutoscaleSettingResourceCollection] + api_version: Literal["2022-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + cls: ClsType[_models.AutoscaleSettingResourceCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -102,16 +107,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -119,13 +131,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("AutoscaleSettingResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -139,7 +151,9 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings" + } @overload async def create_or_update( @@ -212,8 +226,8 @@ async def create_or_update( :type resource_group_name: str :param autoscale_setting_name: The autoscale setting name. Required. :type autoscale_setting_name: str - :param parameters: Parameters supplied to the operation. Is either a model type or a IO type. - Required. + :param parameters: Parameters supplied to the operation. Is either a AutoscaleSettingResource + type or a IO type. Required. :type parameters: ~$(python-base-namespace).v2022_10_01.models.AutoscaleSettingResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -234,9 +248,9 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.AutoscaleSettingResource] + api_version: Literal["2022-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AutoscaleSettingResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -259,9 +273,9 @@ async def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -279,11 +293,13 @@ async def create_or_update( deserialized = self._deserialize("AutoscaleSettingResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -312,8 +328,8 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2022-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -325,9 +341,9 @@ async def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -341,7 +357,9 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}" + } @distributed_trace_async async def get( @@ -370,8 +388,8 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.AutoscaleSettingResource] + api_version: Literal["2022-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + cls: ClsType[_models.AutoscaleSettingResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -383,9 +401,9 @@ async def get( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -403,7 +421,9 @@ async def get( return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}" + } @overload async def update( @@ -480,8 +500,8 @@ async def update( :type resource_group_name: str :param autoscale_setting_name: The autoscale setting name. Required. :type autoscale_setting_name: str - :param autoscale_setting_resource: Parameters supplied to the operation. Is either a model type - or a IO type. Required. + :param autoscale_setting_resource: Parameters supplied to the operation. Is either a + AutoscaleSettingResourcePatch type or a IO type. Required. :type autoscale_setting_resource: ~$(python-base-namespace).v2022_10_01.models.AutoscaleSettingResourcePatch or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -503,9 +523,9 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.AutoscaleSettingResource] + api_version: Literal["2022-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AutoscaleSettingResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -528,9 +548,9 @@ async def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -548,7 +568,9 @@ async def update( return deserialized - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}" + } @distributed_trace def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.AutoscaleSettingResource"]: @@ -564,8 +586,8 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.Autoscal _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.AutoscaleSettingResourceCollection] + api_version: Literal["2022-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + cls: ClsType[_models.AutoscaleSettingResourceCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -586,16 +608,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -603,13 +632,13 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("AutoscaleSettingResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -623,4 +652,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/autoscalesettings"} # type: ignore + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/autoscalesettings" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/aio/operations/_predictive_metric_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/aio/operations/_predictive_metric_operations.py index 1bbabce2f126..5b13f6a38c71 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/aio/operations/_predictive_metric_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/aio/operations/_predictive_metric_operations.py @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime +import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -28,6 +29,10 @@ from ..._vendor import _convert_request from ...operations._predictive_metric_operations import build_get_request +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -99,8 +104,8 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.PredictiveResponse] + api_version: Literal["2022-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + cls: ClsType[_models.PredictiveResponse] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -117,9 +122,9 @@ async def get( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -137,4 +142,6 @@ async def get( return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}/predictiveMetrics"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}/predictiveMetrics" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/models/__init__.py index 40a9ce509de8..e5589ba8fa19 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/models/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/models/__init__.py @@ -39,7 +39,7 @@ from ._monitor_management_client_enums import ScaleType from ._monitor_management_client_enums import TimeAggregationType from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/models/_models_py3.py index bd419fa9f80d..4fa4e68006a8 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/models/_models_py3.py @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, TYPE_CHECKING, Union +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union from ... import _serialization @@ -37,7 +37,7 @@ class AutoscaleErrorResponse(_serialization.Model): "system_data": {"key": "systemData", "type": "SystemData"}, } - def __init__(self, *, error: Optional["_models.AutoscaleErrorResponseError"] = None, **kwargs): + def __init__(self, *, error: Optional["_models.AutoscaleErrorResponseError"] = None, **kwargs: Any) -> None: """ :keyword error: The error object. :paramtype error: ~$(python-base-namespace).v2022_10_01.models.AutoscaleErrorResponseError @@ -74,8 +74,8 @@ def __init__( message: Optional[str] = None, target: Optional[str] = None, details: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword code: One of a server-defined set of error codes. :paramtype code: str @@ -126,8 +126,8 @@ def __init__( *, email: Optional["_models.EmailNotification"] = None, webhooks: Optional[List["_models.WebhookNotification"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword email: the email notification. :paramtype email: ~$(python-base-namespace).v2022_10_01.models.EmailNotification @@ -181,8 +181,8 @@ def __init__( rules: List["_models.ScaleRule"], fixed_date: Optional["_models.TimeWindow"] = None, recurrence: Optional["_models.Recurrence"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword name: the name of the profile. Required. :paramtype name: str @@ -247,7 +247,7 @@ class Resource(_serialization.Model): "system_data": {"key": "systemData", "type": "SystemData"}, } - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: """ :keyword location: Resource location. Required. :paramtype location: str @@ -350,8 +350,8 @@ def __init__( name_properties_name: Optional[str] = None, target_resource_uri: Optional[str] = None, target_resource_location: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword location: Resource location. Required. :paramtype location: str @@ -411,7 +411,9 @@ class AutoscaleSettingResourceCollection(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__(self, *, value: List["_models.AutoscaleSettingResource"], next_link: Optional[str] = None, **kwargs): + def __init__( + self, *, value: List["_models.AutoscaleSettingResource"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword value: the values for the autoscale setting resources. Required. :paramtype value: list[~$(python-base-namespace).v2022_10_01.models.AutoscaleSettingResource] @@ -479,8 +481,8 @@ def __init__( name: Optional[str] = None, target_resource_uri: Optional[str] = None, target_resource_location: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword tags: Resource tags. :paramtype tags: dict[str, str] @@ -542,8 +544,8 @@ def __init__( send_to_subscription_administrator: bool = False, send_to_subscription_co_administrators: bool = False, custom_emails: Optional[List[str]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword send_to_subscription_administrator: a value indicating whether to send email to subscription administrator. @@ -645,8 +647,8 @@ def __init__( metric_resource_location: Optional[str] = None, dimensions: Optional[List["_models.ScaleRuleMetricDimension"]] = None, divide_per_instance: Optional[bool] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword metric_name: the name of the metric that defines what the rule monitors. Required. :paramtype metric_name: str @@ -730,8 +732,8 @@ def __init__( *, scale_mode: Union[str, "_models.PredictiveAutoscalePolicyScaleMode"], scale_look_ahead_time: Optional[datetime.timedelta] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword scale_mode: the predictive autoscale mode. Required. Known values are: "Disabled", "ForecastOnly", and "Enabled". @@ -781,8 +783,8 @@ def __init__( metric_name: Optional[str] = None, target_resource_id: Optional[str] = None, data: Optional[List["_models.PredictiveValue"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword timespan: The timespan for which the data was retrieved. Its value consists of two datetimes concatenated, separated by '/'. This may be adjusted in the future and returned back @@ -828,7 +830,7 @@ class PredictiveValue(_serialization.Model): "value": {"key": "value", "type": "float"}, } - def __init__(self, *, time_stamp: datetime.datetime, value: float, **kwargs): + def __init__(self, *, time_stamp: datetime.datetime, value: float, **kwargs: Any) -> None: """ :keyword time_stamp: the timestamp for the metric value in ISO 8601 format. Required. :paramtype time_stamp: ~datetime.datetime @@ -841,7 +843,8 @@ def __init__(self, *, time_stamp: datetime.datetime, value: float, **kwargs): class Recurrence(_serialization.Model): - """The repeating times at which this profile begins. This element is not used if the FixedDate element is used. + """The repeating times at which this profile begins. This element is not used if the FixedDate + element is used. All required parameters must be populated in order to send to Azure. @@ -866,8 +869,12 @@ class Recurrence(_serialization.Model): } def __init__( - self, *, frequency: Union[str, "_models.RecurrenceFrequency"], schedule: "_models.RecurrentSchedule", **kwargs - ): + self, + *, + frequency: Union[str, "_models.RecurrenceFrequency"], + schedule: "_models.RecurrentSchedule", + **kwargs: Any + ) -> None: """ :keyword frequency: the recurrence frequency. How often the schedule profile should take effect. This value must be Week, meaning each week will have the same set of profiles. For @@ -943,7 +950,7 @@ class RecurrentSchedule(_serialization.Model): "minutes": {"key": "minutes", "type": "[int]"}, } - def __init__(self, *, time_zone: str, days: List[str], hours: List[int], minutes: List[int], **kwargs): + def __init__(self, *, time_zone: str, days: List[str], hours: List[int], minutes: List[int], **kwargs: Any) -> None: """ :keyword time_zone: the timezone for the hours of the profile. Some examples of valid time zones are: Dateline Standard Time, UTC-11, Hawaiian Standard Time, Alaskan Standard Time, @@ -1031,8 +1038,8 @@ def __init__( type: Union[str, "_models.ScaleType"], cooldown: datetime.timedelta, value: str = "1", - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword direction: the scale direction. Whether the scaling action increases or decreases the number of instances. Required. Known values are: "None", "Increase", and "Decrease". @@ -1082,7 +1089,7 @@ class ScaleCapacity(_serialization.Model): "default": {"key": "default", "type": "str"}, } - def __init__(self, *, minimum: str, maximum: str, default: str, **kwargs): + def __init__(self, *, minimum: str, maximum: str, default: str, **kwargs: Any) -> None: """ :keyword minimum: the minimum number of instances for the resource. Required. :paramtype minimum: str @@ -1121,7 +1128,9 @@ class ScaleRule(_serialization.Model): "scale_action": {"key": "scaleAction", "type": "ScaleAction"}, } - def __init__(self, *, metric_trigger: "_models.MetricTrigger", scale_action: "_models.ScaleAction", **kwargs): + def __init__( + self, *, metric_trigger: "_models.MetricTrigger", scale_action: "_models.ScaleAction", **kwargs: Any + ) -> None: """ :keyword metric_trigger: the trigger that results in a scaling action. Required. :paramtype metric_trigger: ~$(python-base-namespace).v2022_10_01.models.MetricTrigger @@ -1167,8 +1176,8 @@ def __init__( dimension_name: str, operator: Union[str, "_models.ScaleRuleMetricDimensionOperationType"], values: List[str], - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword dimension_name: Name of the dimension. Required. :paramtype dimension_name: str @@ -1224,8 +1233,8 @@ def __init__( last_modified_by: Optional[str] = None, last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ :keyword created_by: The identity that created the resource. :paramtype created_by: str @@ -1305,7 +1314,9 @@ class TimeWindow(_serialization.Model): "end": {"key": "end", "type": "iso-8601"}, } - def __init__(self, *, start: datetime.datetime, end: datetime.datetime, time_zone: Optional[str] = None, **kwargs): + def __init__( + self, *, start: datetime.datetime, end: datetime.datetime, time_zone: Optional[str] = None, **kwargs: Any + ) -> None: """ :keyword time_zone: the timezone of the start and end times for the profile. Some examples of valid time zones are: Dateline Standard Time, UTC-11, Hawaiian Standard Time, Alaskan Standard @@ -1363,7 +1374,9 @@ class WebhookNotification(_serialization.Model): "properties": {"key": "properties", "type": "{str}"}, } - def __init__(self, *, service_uri: Optional[str] = None, properties: Optional[Dict[str, str]] = None, **kwargs): + def __init__( + self, *, service_uri: Optional[str] = None, properties: Optional[Dict[str, str]] = None, **kwargs: Any + ) -> None: """ :keyword service_uri: the service address to receive the notification. :paramtype service_uri: str diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/operations/__init__.py index f80e4dc72702..3d1ab289551f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/operations/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/operations/__init__.py @@ -10,7 +10,7 @@ from ._predictive_metric_operations import PredictiveMetricOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/operations/_autoscale_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/operations/_autoscale_settings_operations.py index 928e712a9971..f3ddd199e5a9 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/operations/_autoscale_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/operations/_autoscale_settings_operations.py @@ -6,8 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) # type: str + api_version: Literal["2022-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -55,7 +60,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -72,8 +77,8 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2022-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -89,7 +94,7 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -108,7 +113,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) # type: str + api_version: Literal["2022-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -124,7 +129,7 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -141,7 +146,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) # type: str + api_version: Literal["2022-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -157,7 +162,7 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -174,8 +179,8 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: Literal["2022-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -191,7 +196,7 @@ def build_update_request( "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -208,7 +213,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) # type: str + api_version: Literal["2022-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -217,7 +222,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -266,8 +271,8 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.AutoscaleSettingResourceCollection] + api_version: Literal["2022-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + cls: ClsType[_models.AutoscaleSettingResourceCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -289,16 +294,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -306,13 +318,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("AutoscaleSettingResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -326,7 +338,9 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings"} # type: ignore + list_by_resource_group.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings" + } @overload def create_or_update( @@ -399,8 +413,8 @@ def create_or_update( :type resource_group_name: str :param autoscale_setting_name: The autoscale setting name. Required. :type autoscale_setting_name: str - :param parameters: Parameters supplied to the operation. Is either a model type or a IO type. - Required. + :param parameters: Parameters supplied to the operation. Is either a AutoscaleSettingResource + type or a IO type. Required. :type parameters: ~$(python-base-namespace).v2022_10_01.models.AutoscaleSettingResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -421,9 +435,9 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.AutoscaleSettingResource] + api_version: Literal["2022-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AutoscaleSettingResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -446,9 +460,9 @@ def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -466,11 +480,13 @@ def create_or_update( deserialized = self._deserialize("AutoscaleSettingResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -499,8 +515,8 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: Literal["2022-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -512,9 +528,9 @@ def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -528,7 +544,9 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}" + } @distributed_trace def get( @@ -557,8 +575,8 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.AutoscaleSettingResource] + api_version: Literal["2022-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + cls: ClsType[_models.AutoscaleSettingResource] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -570,9 +588,9 @@ def get( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -590,7 +608,9 @@ def get( return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}" + } @overload def update( @@ -667,8 +687,8 @@ def update( :type resource_group_name: str :param autoscale_setting_name: The autoscale setting name. Required. :type autoscale_setting_name: str - :param autoscale_setting_resource: Parameters supplied to the operation. Is either a model type - or a IO type. Required. + :param autoscale_setting_resource: Parameters supplied to the operation. Is either a + AutoscaleSettingResourcePatch type or a IO type. Required. :type autoscale_setting_resource: ~$(python-base-namespace).v2022_10_01.models.AutoscaleSettingResourcePatch or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. @@ -690,9 +710,9 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) # type: str - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.AutoscaleSettingResource] + api_version: Literal["2022-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AutoscaleSettingResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -715,9 +735,9 @@ def update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -735,7 +755,9 @@ def update( return deserialized - update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}" + } @distributed_trace def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.AutoscaleSettingResource"]: @@ -751,8 +773,8 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.AutoscaleSett _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.AutoscaleSettingResourceCollection] + api_version: Literal["2022-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + cls: ClsType[_models.AutoscaleSettingResourceCollection] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -773,16 +795,23 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -790,13 +819,13 @@ def extract_data(pipeline_response): deserialized = self._deserialize("AutoscaleSettingResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -810,4 +839,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/autoscalesettings"} # type: ignore + list_by_subscription.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Insights/autoscalesettings" + } diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/operations/_predictive_metric_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/operations/_predictive_metric_operations.py index a2cc8f1d91c9..3f732eb810d3 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/operations/_predictive_metric_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2022_10_01/operations/_predictive_metric_operations.py @@ -7,6 +7,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime +import sys from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ( @@ -28,6 +29,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +if sys.version_info >= (3, 8): + from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports +else: + from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,7 +55,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) # type: str + api_version: Literal["2022-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -66,7 +71,7 @@ def build_get_request( "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore # Construct parameters _params["timespan"] = _SERIALIZER.query("timespan", timespan, "str") @@ -149,8 +154,8 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.PredictiveResponse] + api_version: Literal["2022-10-01"] = kwargs.pop("api_version", _params.pop("api-version", "2022-10-01")) + cls: ClsType[_models.PredictiveResponse] = kwargs.pop("cls", None) request = build_get_request( resource_group_name=resource_group_name, @@ -167,9 +172,9 @@ def get( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access request, stream=False, **kwargs ) @@ -187,4 +192,6 @@ def get( return deserialized - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}/predictiveMetrics"} # type: ignore + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}/predictiveMetrics" + }